算法竞赛入门经典(第2版) Box UVa 1587

Box UVa 1587

—————————————————————————
题目:UVa1587
—————————————————————————

思路:暴力求解,十分暴力🐶

Sample Input
1345 2584
2584 683
2584 1345
683 1345
683 1345
2584 683
1234 4567
1234 4567
4567 4321
4322 4567
4321 1234
4321 1234

Sample Output
POSSIBLE
IMPOSSIBLE
#include<bits/stdc++.h>
using namespace std;
pair <int,int> p[6];
int main(){
	while(1) {
		for(int i = 0; i < 6; i++) {
			if(!(cin>>p[i].first>>p[i].second)) return 0;
			if(p[i].first > p[i].second)
				swap(p[i].first,p[i].second);
		}
		sort(p, p+6);
		if(p[0].first==p[1].first && p[0].first==p[2].first && p[0].first==p[3].first && p[0].second==p[1].second && 
		   p[0].second==p[4].first && p[0].second==p[5].first && p[2].second==p[3].second && p[2].second==p[4].second &&
		   p[2].second==p[5].second)
			printf("POSSIBLE\n");
		else
			printf("IMPOSSIBLE\n");	
	}
	return 0;
}

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值