栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

poj 3792 Area of Polycubes

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

poj 3792 Area of Polycubes

#include <iostream>using namespace std;const int MAXP = 100;int dis(int *p1, int *p2){int d = 0;for(int i = 0; i < 3; ++i){d += abs(p1[i] - p2[i]);}return d;}int main(){int N;cin>>N;int points[MAXP][3];for(int no = 0; no < N; ++no){int P;cin>>P;fscanf(stdin, "%d,%d,%d", &points[0][0], &points[0][1], &points[0][2]);int area = 6;bool iscorrect = true;cout<<no + 1<<" ";for(int i = 1; i < P; ++i){fscanf(stdin, "%d,%d,%d", &points[i][0], &points[i][1], &points[i][2]);if(!iscorrect){continue;}area += 6;int j = 0;bool isconnected = false;while(j < i){int d = dis(points[i], points[j]);if(d == 0){break;}if(d == 1){isconnected = true;area -= 2;}j++;}if(j != i || !isconnected){iscorrect = false;cout<<"NO "<<i + 1<<endl;}}if(iscorrect){cout<<area<<endl;}}return 0;}
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/374307.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号