Area of Polycubes poj 3792
2012-12-21 15:50
288 查看
#include <iostream> #include <cstdio> #include <cstdlib> #include <cmath> #include <queue> #include <algorithm> #include <vector> #include <cstring> #include <stack> #include <cctype> #include <utility> #include <map> #include <string> #include <climits> #include <set> #include <string> #include <sstream> #include <utility> #include <ctime> using std::priority_queue; using std::vector; using std::swap; using std::stack; using std::sort; using std::max; using std::min; using std::pair; using std::map; using std::string; using std::cin; using std::cout; using std::set; using std::queue; using std::string; using std::istringstream; using std::make_pair; using std::greater; int move_x[6] = {-1, 0, 1, 0, 0, 0}; int move_y[6] = {0, -1, 0, 1, 0, 0}; int move_z[6] = {0, 0, 0, 0, -1, 1}; struct NODE { int x, y, z; friend bool operator <(const NODE &op1, const NODE &op2) { if(op1.x == op2.x) { if(op1.y == op2.y) return op1.z < op2.z; return op1.y < op2.y; } return op1.x < op2.x; } }; set<NODE> st; int main() { int n_case(0), T; scanf("%d", &T); while(T--) { int n; scanf("%d", &n); int ans = n*3; int flag = -1; NODE t1, t2; st.clear(); scanf("%d,%d,%d", &t1.x, &t1.y, &t1.z); st.insert(t1); for(int i = 2; i <= n; ++i) { scanf("%d,%d,%d", &t1.x, &t1.y, &t1.z); if(flag == -1 && st.find(t1) != st.end()) flag = i; if(flag == -1) { int count = 0; for(int j = 0; j < 6; ++j) { t2 = t1; t2.x += move_x[j]; t2.y += move_y[j]; t2.z += move_z[j]; if(st.find(t2) != st.end()) ++count; } if(count) ans -= count; else flag = i; st.insert(t1); } } if(flag != -1) printf("%d NO %d\n", ++n_case, flag); else printf("%d %d\n", ++n_case, ans*2); } return 0; }
相关文章推荐
- poj 3792 Area of Polycubes (简单模拟)
- poj 3792 Area of Polycubes
- POJ 3792 Area of Polycubes(思维)
- POJ 3792 Area of Polycubes(模拟)
- POJ 3792 Area of Polycubes 解题报告
- POJ 3792 Area of Polycubes 已被翻译
- 南邮 OJ 1537 G ? Area of Polycubes
- liveoj 4238 - Area of Polycubes(搜索)
- Area of Polycubes
- poj 1389 Area of Simple Polygons
- POJ 1389 Area of Simple Polygons(线段树+扫描线+离散化)
- CSU 1697 Surface Area of Cubes (思维)
- POJ-1389-Area of Simple Polygons
- POJ 1389 Area of Simple Polygons
- POJ 1389 Area of Simple Polygons
- poj 1389 Area of Simple Polygons
- hdu 2762 Area of polycube
- 【POJ】1389 Area of Simple Polygons
- POJ 1389 Area of Simple Polygons(面积合并,线段树+离散化)
- 思维 csu1697 Surface Area of Cubes