栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

zoj 2659 Box

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

zoj 2659 Box

#include <iostream>#include <stdio.h>using namespace std;struct Rect{int x;int y;int n;};int main(){int x , y;while(scanf("%d %d",&x,&y)!=EOF){Rect r[3] = {{0,0,0},{0,0,0},{0,0,0}};int f = 0 ; int num = 1;r[0].x = x;r[0].y = y; r[0].n = 1;for( int i= 1 ; i < 6; i++){cin>>x>>y;int ff = 0;for( int j = 0 ; j < num; j++){if((r[j].x==x&&r[j].y==y)||(r[j].x==y&&r[j].y==x)){r[j].n++;ff=1;}}if(ff==0){if(num<3){r[num].x = x;r[num].y = y;r[num].n++;num++;}elsef = 1;}}if( f ==1){cout<<"IMPOSSIBLE"<<endl;}else{int v[3] = {0,0,0};int tx = r[1].x, ty = r[1].y;int tt = 3;if(num==1)tx = ty;else if( num ==2){if(tx==ty&&r[1].n==2){if(tx!=r[0].x&&tx!=r[0].y)tx = -1;}else if(tx!=ty && r[0].n == 4){if(r[0].x!=r[0].y || (tx!=r[0].x&&ty!=r[0].y))tx = -1;}elsetx = -1;}else{if(r[0].n==r[1].n&&r[0].n==r[2].n){for( int k = 0 ; k < 3; k++){if(v[k]==0){if( tx == r[k].x){tx = r[k].y;v[k] = 1;}else if( tx == r[k].y){tx = r[k].x;v[k] = 1;}}}}elsetx = -1;}if(tx==ty)cout<<"POSSIBLE"<<endl;elsecout<<"IMPOSSIBLE"<<endl;}}return 0;}
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/377132.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号