蒻鸡求助
查看原帖
蒻鸡求助
546942
不存在的好吧楼主2021/8/10 14:14
#include<iostream>
#include<string.h>
#include<algorithm>
using namespace std;
typedef struct 
{
    /* data */
    int h; //长度
    int w;  //宽度
    int all;  //总的
}matrix;
matrix side[6];
const int MAXSIZE= 20000;
bool compare(matrix a,matrix b)
{
    if(a.h<b.h) return a.h>b.h;//降序
    else if(a.h == b.h)
    {
        return a.w>b.w;  //降序
    }
}
int main()
{
    while(cin>>side[0].h>>side[0].w>>side[1].h>>side[1].w>>side[2].h>>side[2].w>>side[3].h>>side[3].w>>side[4].h>>side[4].w>>side[5].h>>side[5].w)
    {  
        for(int i=0;i<6;i++)
        {
            if(side[i].h<side[i].w)
            {
                int t=side[i].h;
                side[i].h=side[i].w;
                side[i].w=t;
            }
            side[i].all=side[i].h+side[i].w;
        }
        sort(side,side+6,compare);  
        int k=0;//特判,不为0时表示不满足成长方体的条件
        for(int i=1;i<4;i++)
        {
            if(side[0].h !=side[i].h)
            {
                k=1;
            }
        }
        
        for(int i=3;i<6;i++)
        {
            if(side[2].w !=side[i].w)
            {
                k=1;
            }
        }
        
        if(side[4].h == side[5].h && side[5].h == side[0].w && side[0].w == side[1].w)
        {
        }
        else
        {
            k=1;
        }

        /*if(side[0].h == side[1].h && side[0].w == side[1].w)
        {

        }*/
        /*for(int i=0;i<6;i++)
        {
            cout<<side[i].h<<" "<<side[i].w<<endl;
        }*/
        

        if(k !=1)
        {
            cout<<"POSSIBLE"<<endl;
            //cout<<"IMPOSSIBLE"<<endl;
        }
        else
        {
            cout<<"IMPOSSIBLE"<<endl;
        }
    }
    return 0;
}
2021/8/10 14:14
加载中...