Area of Polycubes(简单模拟)
来源:互联网 发布:thinkpad x系列 知乎 编辑:程序博客网 时间:2024/05/29 21:28
http://poj.org/problem?id=3792
题意:给出n个立方体的三维坐标,在每个立方体与之前的立方体有公共边的前提下输出他们的表面积,否则输出NO,并输出不合法的立方体编号。
注意有重的立方体,也输出NO。
#include <stdio.h>#include <string.h>#include <algorithm>#include <cmath>using namespace std;struct node{int x,y,z;}p[110];int main(){int test;int n;scanf("%d",&test);for(int item = 1; item <= test; item++){scanf("%d",&n);for(int i = 1; i <= n; i++){scanf("%d,%d,%d",&p[i].x,&p[i].y,&p[i].z);}int ok = 1;int ans = 6*n;printf("%d ",item);for(int i = 2; i <= n; i++){int cnt = 0;for(int j = 1; j < i; j++){if(p[i].x == p[j].x && p[i].y == p[j].y && p[i].z == p[j].z){ok = 0;printf("NO %d\n",i);break;}if( (p[i].x == p[j].x && p[i].y == p[j].y && abs(p[i].z-p[j].z) == 1) ||(p[i].x == p[j].x && p[i].z == p[j].z && abs(p[i].y-p[j].y) == 1) ||(p[i].y == p[j].y && p[i].z == p[j].z && abs(p[i].x-p[j].x) == 1) ){ans -=2;cnt++;}}if(ok == 0) break;if(cnt == 0){printf("NO %d\n",i);ok = 0;break;}}if(ok)printf("%d\n",ans);}return 0;}
0 0
- Area of Polycubes(简单模拟)
- POJ 3792 Area of Polycubes(模拟)
- Area of Polycubes poj 3792
- Sicily 1629. Area of Polycubes
- liveoj 4238 - Area of Polycubes(搜索)
- POJ 3792 Area of Polycubes 解题报告
- 南邮 OJ 1537 G ? Area of Polycubes
- Area of Polycubes 使搜索清晰而简化
- POJ 3792 Area of Polycubes 已被翻译
- Area of Interest
- AOI( Area Of Interest )
- hdu4946 Area of Mushroom
- TOJ Area of Circles
- Area of a Parallelogram
- No. 27 - Area of Rectangles
- POJ1389-Area of Simple Polygons
- hdu 4946 Area of Mushroom
- HDU 4946 Area of Mushroom
- 产生一个1-100长度为100不重复的数组
- 文件I/O例子
- JAVA中string.repalce()和string.replaceAll()有什么区别?
- 单例模式
- 算法第四次作業
- Area of Polycubes(简单模拟)
- 栈的两种C++实现
- [LeetCode]10.Regular Expression Matching
- The connection to adb is down, and a severe error has occured.
- CSS布局
- 杭电1592
- 微软创新杯山东省赛成功举办
- apachectl 和 httpd的关系
- ASP.NET 设置DropDownList选中项