UVa.1587

今天效率好差好差的,不爽

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

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
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值