Gym 101630(NEERC 17) D.Designing the Toy
题目大意:给出三视图方向上分别能看到的正方形数a,b,c(1<=a,b,c<=100),在-100<=x,y,z<=100的范围内构造出满足情况的一种正方体的摆放方式
做法很简单,首先找到a,b,c中的最大值,如果最大值满足小于等于另两个值的乘积,则有解,否则无解;明确这一点之后,便可以将所有正方体平铺在最大值所在的平面上进行构造。
#include<bits/stdc++.h>
using namespace std; typedef long long ll;
const int mod=1e9+;
const int maxn=1e5+;
const int inf=0x3f3f3f3f;
const double eps=1e-;
const double pi=acos(-1.0);
#define mem(s,v) memset(s,v,sizeof(s))
#define pdd pair<double,double>
#define pii pair<int,int> struct node{
int num,id;
};
node a[]; int cmp(node x,node y){
return x.num<y.num;
} int mp[][]; int main(){
while(~scanf("%d%d%d",&a[].num,&a[].num,&a[].num)){
memset(mp,,sizeof(mp));
for(int i=;i<;++i) a[i].id=i+;
sort(a,a+,cmp);
if(a[].num>a[].num*a[].num){
puts("-1");
continue;
}
int j=;
for(int i=;i<a[].num;++i){
if(j<a[].num){
mp[i][j]=;
j++;
}
else{
mp[i][j-]=;
}
}
int t=a[].num-a[].num;
for(int i=;i<t;++i){
int flag=;
for(int k=;k<a[].num;++k){
for(int j=;j<a[].num;++j){
if(!mp[k][j]){
mp[k][j]=;
flag=;
break;
}
}
if(!flag) break;
}
}
printf("%d\n",a[].num);
int x,y,z;
if(a[].id==){
z=;
if(a[].id==){
for(int i=;i<a[].num;++i){
for(int j=;j<a[].num;++j){
if(mp[i][j]) printf("%d %d %d\n",i,j,z);
}
}
}
else if(a[].id==){
for(int i=;i<a[].num;++i){
for(int j=;j<a[].num;++j){
if(mp[i][j]) printf("%d %d %d\n",j,i,z);
}
}
}
}
else if(a[].id==){
y=;
if(a[].id==){
for(int i=;i<a[].num;++i){
for(int j=;j<a[].num;++j){
if(mp[i][j]) printf("%d %d %d\n",i,y,j);
}
}
}
else if(a[].id==){
for(int i=;i<a[].num;++i){
for(int j=;j<a[].num;++j){
if(mp[i][j]) printf("%d %d %d\n",j,y,i);
}
}
}
}
else if(a[].id==){
x=;
if(a[].id==){
for(int i=;i<a[].num;++i){
for(int j=;j<a[].num;++j){
if(mp[i][j]) printf("%d %d %d\n",x,j,i);
}
}
}
else if(a[].id==){
for(int i=;i<a[].num;++i){
for(int j=;j<a[].num;++j){
if(mp[i][j]) printf("%d %d %d\n",x,i,j);
}
}
}
}
}
return ;
}
Gym 101630(NEERC 17) D.Designing the Toy的更多相关文章
- 2017-2018 ACM-ICPC Northern Eurasia (Northeastern European Regional) Contest (NEERC 17) 日常训练
A - Archery Tournament 题目大意:按时间顺序出现靶子和射击一个位置,靶子的圆心为(x, y)半径为r,即圆与x轴相切,靶子不会重叠,靶子被击中后消失, 每次射击找出哪个靶子被射中 ...
- 2017-2018 ACM-ICPC Northern Eurasia (Northeastern European Regional) Contest (NEERC 17)
2017-2018 ACM-ICPC Northern Eurasia (Northeastern European Regional) Contest (NEERC 17) A 题意:有 n 个时刻 ...
- Codeforces Gym 101190 NEERC 16 .D Delight for a Cat (上下界的费用流)
ls是一个特别堕落的小朋友,对于n个连续的小时,他将要么睡觉要么打隔膜,一个小时内他不能既睡觉也打隔膜 ,因此一个小时内他只能选择睡觉或者打隔膜,当然他也必须选择睡觉或打隔膜,对于每一个小时,他选择睡 ...
- Codeforces Gym 101190 NEERC 16 .L List of Primes(递归)
ls特别喜欢素数,他总是喜欢把素数集合的所有子集写下来,并按照一定的顺序和格式.对于每一个子集,集合内 的元素在写下来时是按照升序排序的,对于若干个集合,则以集合元素之和作为第一关键字,集合的字典序作 ...
- Codeforces Gym 101190 NEERC 16 G. Game on Graph(博弈+拓扑)
Gennady and Georgiy are playing interesting game on a directed graph. The graph has n vertices and m ...
- 2017 NEERC
2017 NEERC Problem A. Archery Tournament 题目描述:在二维平面上,会陆续出现一些圆,以及一些询问,询问点是否在圆内,如果是,则输出那个圆,并把那个圆删掉,否则输 ...
- [C++]Yellow Cards - GYM - 102348A(Practice *) - CodeForces
1 Problem Description Problem The final match of the Berland Football Cup has been held recently. Th ...
- Codeforces Gym 101630J Travelling from Petersburg to Moscow (最短路)
题目链接 http://codeforces.com/gym/101630/attachments 题解 zyb学长的题. 先枚举第\(k\)大的边权,设其边权为\(x\),然后把每条边边权减掉\(x ...
- NEERC-2017
A. Archery Tournament 用线段树套set维护横坐标区间内的所有圆,查询时在$O(\log n)$个set中二分查找即可. 时间复杂度$O(n\log^2n)$. #include& ...
随机推荐
- Codeforces 859C - Pie Rules
859C - Pie Rules 思路: dp 我们知道无论谁拿到decider token他拿不拿蛋糕都是确定的,都是使自己最优的结果. 于是 定义状态:dp[i]表示到第i个位置拿到decider ...
- Interactive Reporting , SQL*Net not loaded successfully 问题的解决。
.bashrc 什么的,早就把 TNS_ADMIN , 和 LD_LIBRARY_PATH 加进去了,可就是不好使. 终极方法还是在 workspace 的 R&A -> Service ...
- android--------ExpandableListView的使用多级列表
多级列表ExpandableListView 扩展列表能够显示一个指示在每项显示项的当前状态(状态通常是一个扩展的组,组的孩子,或倒塌,最后一个孩子).使用setchildindicator(draw ...
- Sonya and Ice Cream CodeForces - 1004E 树的直径, 贪心
题目链接 set维护最小值贪心, 刚开始用树的直径+单调队列没调出来... #include <iostream>#include <cstdio> #include < ...
- hdu6394Tree lct
树上弹飞绵羊,现场树分块没写出来= = 先预处理倍增,新建一个n+1节点,能弹到就建一条边,然后每操作2就cut,然后link,1的答案就是x到n+1的距离, //#pragma GCC optimi ...
- HBase基于region数目和data locality来balance regions
1. 在Hbase的运维过程中,我们经常需要做如下操作: 移动 regionserver 到其他的 regionserver group中 下线一台机器 增加一台机器 移动 table 到其他 re ...
- POJ-3414 Pots (BFS)
Description You are given two pots, having the volume of A and B liters respectively. The following ...
- OC NSArray数组排序
一.一般排序 // 排序 NSArray *arr = @["]; NSArray *newarr = [arr sortedArrayUsingSelector:@selector(com ...
- Python学习之路day3-集合
一.概述 集合(set)是一种无序且不重复的序列. 无序不重复的特点决定它存在以下的应用场景: 去重处理 关系测试 差集.并集.交集等,下文详述. 二.创建集合 创建集合的方法与创建字典类似,但没有键 ...
- POJ 1754 线段树
e,应该是线段树里的水题.线段树单点更新.查询区间最值. 代码套用模板 PS :模板有些地方不太懂. #include<stdio.h>#include<iostream>#i ...