盒子Box UVA1587
来源:互联网 发布:协方差矩阵 编辑:程序博客网 时间:2024/05/29 16:57
- #include<cstdio>
- #include<set>
- #include<string.h>
- using namespace std;
- struct note{
- int w,h;
- int flag;//用于判断是否被访问过 0表示被访问过
- const bool operator==(const note &n)const {
- return n.w==this->w && n.h==this->h || n.w==this->h&&n.h==this->w;
- }
- note(){this->flag=1;}
- };
- int main(){
- int w,h;
- while(scanf("%d%d",&w,&h)==2){
- note n1[7];
- set<int>s;
- n1[0].w=w;
- n1[0].h=h;
- for(int i=1;i<6;i++)
- {
- scanf("%d%d",&n1[i].w,&n1[i].h);
- s.insert(n1[i].w);
- s.insert(n1[i].h);
- }
- //此处判断是否有三对 相同
- int count =0;
- for(int i=0;i<6;i++){
- for(int j=i+1;j<6;j++)
- if(n1[j].flag && n1[i].flag){
- if(n1[i]==n1[j])
- {
- count++;
- n1[j].flag=0;
- break;
- }
- }
- if(count==3)break;
- }
- //输入一组数据中最多有三种不同1、全相同;2、两种(4条相同 、8条相同);3、(4,4,4)
- int ok=0;
- int length=s.size();
- if(length==1)ok=1;
- else if(length==2){
- int count=0;
- set<int>::iterator iter1=s.begin();
- for(int i=0;i<6;i++)
- {
- if(*iter1==n1[i].w)count++;
- if(*iter1==n1[i].h)count++;
- }
- if(count==4 ||count==8)ok=1;
- }
- else if(length==3){
- int count =0;
- set<int>::iterator iter1=s.begin();
- for(int i=0;i<6;i++)
- {
- if(*iter1==n1[i].w)count++;
- if(*iter1==n1[i].h)count++;
- }
- if(count==4)ok=1;
- }
- if(count==3 && ok)printf("POSSIBLE\n");
- else printf("IMPOSSIBLE\n");
- }
- return 0;
- }
1 0
- 盒子Box UVA1587
- UVa1587--Box--盒子(代码超简洁)
- UVa1587 盒子
- UVa1587 盒子
- UVa1587 盒子
- UVa1587 盒子
- UVa1587 盒子
- Uva1587 - Box
- uva1587 - Box
- UVa1587-Box
- [UVA1587]BOX
- uva1587 - Box
- UVa1587 - Box
- UVa1587-Box
- 算法竞赛入门经典(第2版)习题3-10 盒子 Box UVa1587
- 《算法竞赛入门经典2ndEdition 》习题3-10 盒子(Box, Uva1587)
- 习题3-10 盒子(Box, ACM/ICPC NEERC 2004, UVa1587)
- uva1587——box
- Spring Batch 简介(一)
- 深入浅出RxJava四-在Android中使用响应式编程
- RPC在neutron中的应用,比较详细的介绍了如何使用
- java中RSA加解密的实现
- Java向上转型和向下转型
- 盒子Box UVA1587
- 互联网业务安全
- 我的python之路
- 使用bindService方式启动Service
- mysql 索引基础
- 离线状态下android studio的tesseract配置方法
- MVC MVP MVVM
- Python中BeautifulSoup的常用操作
- 悠游书城