UVa.1587

来源:互联网 发布:淘宝会员折扣没有了 编辑:程序博客网 时间:2024/06/05 10:25
今天效率好差好差的,不爽

这题就是判断给出的六个面能否组成长方体

1.判断能否两两对称
2.判断对称的三个面中能否组成长方体(正方体也可以)

以上

#include<stdio.h>#include<string.h>#include<algorithm>#include<iostream>//using namespace std;char *ans[2]={"POSSIBLE","IMPOSSIBLE"};char *ansb[1010];int jud[6];int wh[6][3],newwh[4][3];bool ok(){if(newwh[0][0]==newwh[2][0] && newwh[0][1]==newwh[1][1] && newwh[1][0]==newwh[2][1])return true;if(newwh[0][0]==newwh[2][0] && newwh[0][1]==newwh[1][0] && newwh[1][1]==newwh[2][1])return true;if(newwh[0][0]==newwh[1][0] && newwh[0][1]==newwh[2][1] && newwh[1][1]==newwh[2][0])return true;if(newwh[0][0]==newwh[1][0] && newwh[0][1]==newwh[2][0] && newwh[1][1]==newwh[2][1])return true;if(newwh[1][0]==newwh[2][0] && newwh[0][0]==newwh[1][1] && newwh[0][1]==newwh[2][1])return true;if(newwh[1][0]==newwh[2][0] && newwh[0][0]==newwh[2][1] && newwh[0][1]==newwh[1][1])return true;if(newwh[0][0]==newwh[1][0] && newwh[1][0]==newwh[2][0] && newwh[2][0]==newwh[0][1] && newwh[0][1]==newwh[12][1] && newwh[1][1]==newwh[2][1])return true;return false;}int main(){int sb=0;while(scanf("%d %d",&wh[0][0],&wh[0][1])!=EOF){if(wh[0][0]>=wh[0][1]){int t=wh[0][0];wh[0][0]=wh[0][1];wh[0][1]=t;}for(int i=1;i<6;i++){//这里输入六组数据scanf("%d %d",&wh[i][0],&wh[i][1]);//这里让每组数据都按从小到大的顺序排列if(wh[i][0]>=wh[i][1]){int t=wh[i][0];wh[i][0]=wh[i][1];wh[i][1]=t;}}int t=0;for(int i=0;i<6;i++){for(int j=i+1;j<6;j++){if(wh[i][0]==wh[j][0]&&wh[i][1]==wh[j][1]){newwh[t][0]=wh[i][0];newwh[t][1]=wh[i][1];t++;}}}if(t<=3){ansb[sb]=ans[1];sb++;break;;}if(ok()){ansb[sb]=ans[0];sb++;break;}else  ansb[sb]=ans[1];sb++;break;}for(int bs=0;bs<sb;bs++){printf("%s\n",ansb[bs]);}return 0;}

0 0
原创粉丝点击