Uva 1587:Box
来源:互联网 发布:java file 相对路径 编辑:程序博客网 时间:2024/06/06 06:50
题目传送门:https://cn.vjudge.net/problem/UVA-1587
#include <stdio.h>struct p{ int w, h;}ps[6], cps[3];bool isSame(int i, int j){ return (ps[i].w == ps[j].w && ps[i].h == ps[j].h) || (ps[i].w == ps[j].h && ps[i].h == ps[j].w);}bool dfs(int a, int b, int depth) // 旋转拼接三个板子{ if (2 == depth) { if (a == cps[depth].w && b == cps[depth].h) return true; if (a == cps[depth].h && b == cps[depth].w) return true; return false; } if (cps[depth].w == a) if (dfs(cps[depth].h, b, depth+1)) return true; if (cps[depth].h == a) if (dfs(cps[depth].w, b, depth+1)) return true; return false;}int main(){ while (2 == scanf("%d%d", &ps[0].w, &ps[0].h)) { bool used[6] = {false}; int ct = 0; for (int i = 1; i < 6; ++i) scanf("%d%d", &ps[i].w, &ps[i].h); for (int i = 0, j; i < 6; ++i) { // 首先确定是否有三对相同的板子 if (used[i]) continue; for (j = i + 1; j < 6; ++j) { if (used[j]) continue; if (isSame(i, j)) { used[i] = used[j] = true; cps[ct++] = ps[i]; // 记住三组板子 break; } } if (6 == j) break; } //printf("ct = %d\n", ct); if (ct < 3) { printf("IMPOSSIBLE\n"); continue; } if (dfs(cps[0].w, cps[0].h, 1) || dfs(cps[0].h, cps[0].w, 1)) // 旋转拼接三个板子 printf("POSSIBLE\n"); else printf("IMPOSSIBLE\n"); } return 0;}
0 0
- uva 1587 - Box
- uva 1587 - Box
- UVa 1587 - Box
- UVa 1587 - Box
- UVa 1587 Box
- Uva-1587-Box-AC
- UVA - 1587 Box
- UVa 1587 Box
- Box UVa 1587
- UVA - 1587 Box 麻烦
- UVa 1587 - Box
- UVa 1587 - Box
- UVa-1587 - Box
- UVa 1587 Box
- Uva - 1587 - Box
- UVA - 1587 Box
- UVA 1587 BOX
- UVa 1587 BOX
- 博客第一篇文
- Android无法收到指定广播的问题总结
- ZOJ2482 IP Address
- nginx配置虚拟机
- 多线程之生产者与消费者模式
- Uva 1587:Box
- 内存
- Ubiquitous Religions
- 使用SecureCRT配置虚拟机的简记
- 最小的K个数
- JSONObject、JSONArray
- 对象管理资源
- leetcode 131 Palindrome Partitioning
- HDU1245