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& ...
随机推荐
- Selenium之Action Chains类
Action Chains类常用于模拟鼠标的行为,比如单击,双击,拖拽等行为,使用下面的方法导入Action Chains类 from selenium.webdriver.common.action ...
- 关于安装php时 --with-mysql命令参数问题
如果是rpm安装mysql则直接写成--with-mysql 如果是编译安装mysql则写成--with-mysql=mysql安装路劲 如果你还没有安装Mysql数据库,可以暂时不编译
- android沉浸状态栏和顶部状态栏背景色的设置
法一: 现在很多应用都引用了沉浸式状态栏,如QQ,效果下图: 这样的效果很酷炫,其实设置很简单. 不过要说明的是,这种效果只能在API19以及以上版本中才能够做到. 如果想让界面Activity中实现 ...
- hdu 2018多校8
A.Character Encoding 简单计数 m个非负数和等于k的方案数为$\binom{m+k-1}{k}$, 但题目还要求每个数小于n, 容斥一下即可 即$ans = \sum\limits ...
- 『cs231n』作业3问题3选讲_通过代码理解图像梯度
Saliency Maps 这部分想探究一下 CNN 内部的原理,参考论文 Deep Inside Convolutional Networks: Visualising Image Classifi ...
- 微信公众号开发之如何一键导出微信所有用户信息到Excel
微信开发交流群:148540125 系列文章参考地址 极速开发微信公众号欢迎留言.转发.打赏 项目源码参考地址 点我点我--欢迎Start 极速开发微信公众号系列文章之如何一键导出微信所有用户信息到E ...
- UVA-11584 Partitioning by Palindromes (简单线性DP)
题目大意:给一个全是小写字母的字符串,判断最少可分为几个回文子序列.如:“aaadbccb” 最少能分为 “aaa” “d” “bccb” 共三个回文子序列,又如 “aaa” 最少能分为 1 个回文子 ...
- transition多个属性同时渐变(width,height,background)
<!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml"><head> < ...
- Oracle12c中多宿主环境(CDB&PDB)的数据库触发器(Database Trigger)
Oracle12c中可插拔数据库(PDBs)上的多宿主数据库触发器 随着多宿主选项的引入,数据库事件触发器可以在CDB和PDB范围内创建. 1. 触发器范围 为了在CDB中创建数据库事件触发器,需 ...
- BZOJ3544 [ONTAK2010]Creative Accounting
看不懂题,就不能写的稍微像人话点吗我去... 题目就是要找一段区间使得Σai mod m的值最大. 于是嘛...前缀和一下再贪心就好了. 先求出前i个数的前缀和s,然后用s更新解. 还有可能就是前面的 ...