Box
UVA - 1587
题目传送门
解决方法:按照边在12个长宽出现的次数和出现在几个矩形里来判定就行了
总共出现一个长度,满足条件
总共出现两个长度,则其中一个长度在12个数里出现4次,并在四个矩形中出现
总共出现三个长度,则必须每个长度都出现4次,并在四个矩形中出现
AC代码:
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <bitset>
#include <set>
#include <utility>
#include <sstream>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define inf 0x3f3f3f3f
#define rep(i,l,r) for(int i=l;i<=r;i++)
#define lep(i,l,r) for(int i=l;i>=r;i--)
#define ms(arr) memset(arr,0,sizeof(arr))
//priority_queue<int,vector<int> ,greater<int> >q;
const int maxn = (int)1e5 + 5;
const ll mod = 1e9+7;
struct node
{int x;int y;
}arr[20];
int num[20];
int main()
{#ifndef ONLINE_JUDGEfreopen("in.txt", "r", stdin);#endif//freopen("out.txt", "w", stdout);ios::sync_with_stdio(0),cin.tie(0);while(scanf("%d %d",&arr[1].x,&arr[1].y)!=EOF){ms(num);set<int> s;s.insert(arr[1].x);s.insert(arr[1].y);rep(i,2,6) {scanf("%d %d",&arr[i].x,&arr[i].y);s.insert(arr[i].x);s.insert(arr[i].y);}set<int>::iterator ite;int t=0;for(ite=s.begin();ite!=s.end();ite++)num[++t]=*ite;if(s.size()==1)printf("POSSIBLE\n");else if(s.size()==2){int num1=0,num2=0;rep(i,1,6) {if(arr[i].x==num[1]||arr[i].y==num[1])num1++;if(arr[i].x==num[2]||arr[i].y==num[2])num2++;}if((num1==6&&num2==4)||(num1==4&&num2==6))printf("POSSIBLE\n");elseprintf("IMPOSSIBLE\n");}else if(s.size()==3){int num1=0,num2=0,num3=0;rep(i,1,6) {if(arr[i].x==num[1]||arr[i].y==num[1])num1++;if(arr[i].x==num[2]||arr[i].y==num[2])num2++;if(arr[i].x==num[3]||arr[i].y==num[3])num3++;}if(num1==num2&&num2==num3&&num3==4)printf("POSSIBLE\n");elseprintf("IMPOSSIBLE\n");}elseprintf("IMPOSSIBLE\n");}return 0;
}