1587 - Box

Moderator: Board moderators

saju10
New poster
Posts: 8
Joined: Mon Nov 18, 2013 12:09 am

1587 - Box

why wrong ans.......?
here given my code.......

Code: Select all

``````#include<stdio.h>
int main()
{
int a1,a2,b1,b2,c1,c2,d1,d2,e1,e2,f1,f2;
while(scanf("%d%d%d%d%d%d%d%d%d%d%d%d",&a1,&a2,&b1,&b2,&c1,&c2,&d1,&d2,&e1,&e2,&f1,&f2)==12)
{
int relation=0;
if((a1==b1&&a2==b2)||(a2==b1&&a1==b2))
{
relation++;
b1=0;
}
else if((a1==c1&&a2==c2)||(a2==c1&&a1==c2))
{
relation++;
c1=0;
}
else if((a1==d1&&a2==d2)||(a2==d1&&a1==d2))
{
relation++;
d1=0;
}
else if((a1==e1&&a2==e2)||(a2==e1&&a1==e2))
{
relation++;
e1=0;
}
else if((a1==f1&&a2==f2)||(a2==f1&&a1==f2))
relation++;
if(b1!=0)
{
if((b1==c1&&b2==c2)||(b2==c1&&b1==c2))
{
relation++;
c1=0;
}
else if((b1==d1&&b2==d2)||(b2==d1&&b1==d2))
{
relation++;
d1=0;
}
else if((b1==e1&&b2==e2)||(b2==e1&&b1==e2))
{
relation++;
e1=0;
}
else if((b1==f1&&b2==f2)||(b2==f1&&b1==f2))
relation++;
}
if(c1!=0)
{
if((c1==d1&&c2==d2)||(c2==d1&&c1==d2))
{
relation++;
d1=0;
}
else if((c1==e1&&c2==e2)||(c2==e1&&c1==e2))
{
relation++;
e1=0;
}
else if((c1==f1&&c2==f2)||(c2==f1&&c1==f2))
relation++;
}
if(d1!=0)
{
if((d1==e1&&d2==e2)||(d2==e1&&d1==e2))
{
relation++;
e1=0;
}
else if((d1==f1&&d2==f2)||(d2==f1&&d1==f2))
relation++;
}

if(e1!=0)
if((e1==f1&&e2==f2)||(e2==f1&&e1==f2))
relation++;
if(relation==3)
printf("POSSIBLE\n");
else
printf("IMPOSSIBLE\n");
}
return 0;
}``````

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 1587 - Box

I put this post in it's own thread.

Input:

Code: Select all

``````1 2
2 1
3 1
2 2
1 2
3 3
3 2
1 1
1 1
3 2
2 3
3 1
1 2
3 1
3 1
3 3
3 2
3 2
3 1
2 1
1 3
2 2
3 2
2 3
2 1
1 2
3 1
3 1
2 3
3 3
3 3
1 1
2 3
3 3
2 2
2 3
2 2
3 1
1 2
2 2
1 2
3 3
1 1
1 3
2 3
2 1
1 1
2 3
1 2
1 2
1 2
1 3
3 1
2 2
1 3
2 2
1 1
2 2
2 2
1 2
3 3
2 1
3 3
3 3
1 1
3 3
3 3
3 2
3 2
2 2
3 3
2 2
3 1
2 3
3 1
1 3
3 2
2 3
3 3
2 2
3 1
1 1
3 2
2 1
3 2
3 1
2 3
1 1
1 2
3 3
3 3
2 2
1 3
2 1
3 1
2 1
3 2
2 3
3 2
1 3
1 3
2 1
1 3
1 1
3 2
3 2
3 2
1 1
2 3
1 3
1 2
1 3
2 3
2 2
2 2
2 3
3 3
2 1
1 1
3 3
``````
AC output:

Code: Select all

``````IMPOSSIBLE
IMPOSSIBLE
IMPOSSIBLE
IMPOSSIBLE
IMPOSSIBLE
IMPOSSIBLE
IMPOSSIBLE
IMPOSSIBLE
IMPOSSIBLE
IMPOSSIBLE
IMPOSSIBLE
IMPOSSIBLE
IMPOSSIBLE
IMPOSSIBLE
IMPOSSIBLE
IMPOSSIBLE
IMPOSSIBLE
IMPOSSIBLE
IMPOSSIBLE
IMPOSSIBLE
``````
Check input and AC output for thousands of problems on uDebug!

dnflove202
New poster
Posts: 1
Joined: Sat Nov 21, 2015 12:23 pm

Re: 1587 - Box

Code: Select all

``````#include<iostream>
using namespace std;
int main()
{
int k=0;
int longth[6],wideth[6];
for(int j=0;j<6;j++)
cin>>longth[j]>>wideth[j];
for(int j=0;j<6;j++)
if(longth[j] > wideth[j])
{
k=longth[j];
longth[j]=wideth[j];
wideth[j]=k;
k=0;
}
for(int i=0;i<5;)
{
for(int j=i+1;j<6;j++)
if(longth[i] == longth[j] && wideth[i] == wideth[j])
{
longth[j]=0;
wideth[j]=0;
break;
}
i++;
}
for(int i=0;i<6;i++)
if(longth[i]>0) k++;
if( k>3 )
{
cout<<"IMPOSSIBLE";
goto breakup;
}
else
{
for(int i=0;i<5;i++)
for(int j=0;j<5-i;j++)
if(longth[j]>longth[j+1])
{
k=longth[j+1];
longth[j+1]=longth[j];
longth[j]=k;
k=wideth[j+1];
wideth[j+1]=wideth[j];
wideth[j]=k;
}
if ( (longth[3] == longth[4] && wideth[3]==longth[5] && wideth[4] == wideth[5]) ||
(longth[3] == longth[4] && wideth[4]==longth[5] && wideth[3] == wideth[5]) ||
(wideth[3] == wideth[5] && longth[3]==wideth[4] && longth[4] == wideth[5])	||
(wideth[3] == wideth[4] && longth[3]==wideth[5] && longth[4] == wideth[5]) )
cout<<"POSSIBLE";
else cout<<"IMPOSSIBLE";
}
breakup:return 0;

}
``````
I don't know what is wrong! T_T