UVA 1587 Box(模拟)
来源:互联网 发布:电脑刻碟用什么软件 编辑:程序博客网 时间:2024/06/05 23:45
题目地址:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=448&page=show_problem&problem=4462
思路:分三种面,模拟,注意判断每种面的个数。
#include<map>#include<cstdio>#include<cstring>#include<iostream>#include<algorithm>#define debuusing namespace std;struct Node{ int x,y; bool operator == (const Node &rhs) const { return x==rhs.x&&y==rhs.y; } bool operator < (const Node &rhs) const { if(x==rhs.x) return y<rhs.y; else return x<rhs.x; }};map<Node,int> M;Node a[10],b[10];int main(){#ifdef debug freopen("in.in","r",stdin);#endif // debug int tot=0,x,y; while(scanf("%d%d",&x,&y)!=EOF) { tot%=6,a[tot]=(Node) {min(x,y),max(x,y)},tot+=1; if(tot==6) { M.clear(); for(int i=0; i<6; i++) M[a[i]]++; int flag=0; sort(a,a+6); int num=unique(a,a+6)-a; if(num==3) { if(M[a[0]]==2&&M[a[1]]==2&&M[a[2]]==2) { do { if(a[0].x==a[2].x&&a[1].y==a[0].y&&a[2].y==a[1].x) { flag=1; break; } } while(next_permutation(a,a+3)); } } else if(num==1) { if(a[0].x==a[0].y) flag=1; } else if(num==2) { if((M[a[0]]==4&&M[a[1]]==2)||(M[a[1]]==2&&M[a[0]]==4)) { b[0]=a[0],b[1]=a[1],b[2]=a[0]; do { if(b[0].x==b[2].x&&b[1].y==b[0].y&&b[2].y==b[1].x) { flag=1; break; } } while(next_permutation(b,b+3)); b[0]=a[0],b[1]=a[1],b[2]=a[1]; do { if(b[0].x==b[2].x&&b[1].y==b[0].y&&b[2].y==b[1].x) { flag=1; break; } } while(next_permutation(b,b+3)); } } if(!flag) printf("IMPOSSIBLE\n"); else printf("POSSIBLE\n"); } } return 0;}
0 0
- UVA 1587 Box(模拟)
- UVa 1587 Box(暴力)
- UVA - 1587 Box :锻炼了我的模拟能力
- UVa 1587 Box (判断长方体)
- UVa 591 Box of Bricks (模拟)
- UVA 591 ---Box of Bricks 模拟枚举
- 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
- ubuntu备份数据库
- spring 配置触发器
- 在RHEL7下 启动图形化界面(x windows)
- Linux学习之——shell脚本的执行方式和快捷键
- 带你玩-Object Tracking using OpenCV (一)
- UVA 1587 Box(模拟)
- 关于Console控制台输出的玩法
- swift中嵌入oc代码
- WPF 自定义快捷键命令(Command)
- jmeter工作原理
- 浅谈:FloatingActionMenu的用法
- Android Instant Run 热更新
- Javaweb获取表单数据的几种方式
- 传智播客 srping依赖注入原理详解