All about problems in Volume 119. If there is a thread about your problem, please use it. If not, create one with its number in the subject.
Moderator: Board moderators
plamplam
Experienced poster
Posts: 150 Joined: Fri May 06, 2011 11:37 am
Post
by plamplam » Sun Jul 03, 2011 3:36 pm
Hi, I solved this problem after getting 4 Wrong Answers. My first solution was wrong, so I had to prepare another correct solution. Here are some test cases which helped me find my mistake. Hope this will help anyone getting Wrong Answer, but try it yourself first:) May be that is the best way to learn.
Code: Select all
15
123456 125634
123456 465231
123456 465132
123456 461325
641325 465231
641325 463251
463152 641325
456789 458967
351624 465231
641325 461325
123654 351624
111111 111111
111211 211111
111112 112111
512512 215215
Code: Select all
Equal
Not Equal
Equal
Equal
Equal
Not Equal
Equal
Equal
Not Equal
Not Equal
Not Equal
Equal
Equal
Equal
Equal
You tried your best and you failed miserably. The lesson is 'never try'. -Homer Simpson
yeasin_acm_solver
New poster
Posts: 11 Joined: Wed Jun 09, 2010 2:30 pm
Location: University Of Science & Technology Chittagong (USTC) Bangladesh
Post
by yeasin_acm_solver » Tue Jul 05, 2011 10:34 pm
i can't understand this input output case :
input:
1
123456 461325
output:
Equal
Can anyone help me by explain how it is possible ?
plamplam
Experienced poster
Posts: 150 Joined: Fri May 06, 2011 11:37 am
Post
by plamplam » Wed Jul 06, 2011 8:09 pm
Sure, its a pleasure.
Flip the dice once side-wise to the right. Now you have this combination:
463251
Now turn the dice once(90 degrees) clockwise, and there you go 461325. At first I checked if there are three pairs in the second string with the same opposite faces as in the first string, but then I realized that this doesn't always show correct output. Why don't you grab a dice and try it for yourself? You can also try making a small box with paper and numbering the faces as required, if you are struggling to understand my reasoning. Good luck
You tried your best and you failed miserably. The lesson is 'never try'. -Homer Simpson
tzupengwang
New poster
Posts: 36 Joined: Fri Dec 02, 2011 1:30 pm
Location: Kaohsiung, Taiwan
Post
by tzupengwang » Thu Sep 06, 2012 2:19 pm
I was struggling with the problem and at the end I decided to state the 24 possibilities of a dice and compare it one by one?I'm curious why I get WA!!
Can anyone help? thanks
Code: Select all
/*11959*/
#include<stdio.h>
#include<algorithm>
using namespace std;
int in;
int s1[7],s2[7];
int opp[11];
void READ()
{
scanf("%d",&in);
for (int i=6;i>0;i--)
{
s1[i]=in%10;
in/=10;
}
scanf("%d",&in);
for (int i=6;i>0;i--)
{
s2[i]=in%10;
in/=10;
}
}
int main()
{
//freopen("in.txt","r",stdin);
//freopen("out.txt","w",stdout);
int amm;
scanf("%d",&amm);
while (amm--)
{
READ();
if (s1[1]==s2[1]&&s1[2]==s2[2]&&s1[3]==s2[3]&&s1[4]==s2[4]&&s1[5]==s2[5]&&s1[6]==s2[6])printf("Equal\n");
else if(s1[1]==s2[1]&&s1[2]==s2[2]&&s1[3]==s2[6]&&s1[4]==s2[3]&&s1[5]==s2[4]&&s1[6]==s2[5])printf("Equal\n");
else if(s1[1]==s2[1]&&s1[2]==s2[2]&&s1[3]==s2[5]&&s1[4]==s2[6]&&s1[5]==s2[3]&&s1[6]==s2[4])printf("Equal\n");
else if(s1[1]==s2[1]&&s1[2]==s2[2]&&s1[3]==s2[4]&&s1[4]==s2[5]&&s1[5]==s2[6]&&s1[6]==s2[3])printf("Equal\n");
else if(s1[1]==s2[2]&&s1[2]==s2[1]&&s1[3]==s2[6]&&s1[4]==s2[5]&&s1[5]==s2[4]&&s1[6]==s2[3])printf("Equal\n");
else if(s1[1]==s2[2]&&s1[2]==s2[1]&&s1[3]==s2[5]&&s1[4]==s2[4]&&s1[5]==s2[3]&&s1[6]==s2[6])printf("Equal\n");
else if(s1[1]==s2[2]&&s1[2]==s2[1]&&s1[3]==s2[4]&&s1[4]==s2[3]&&s1[5]==s2[6]&&s1[6]==s2[5])printf("Equal\n");
else if(s1[1]==s2[2]&&s1[2]==s2[1]&&s1[3]==s2[3]&&s1[4]==s2[6]&&s1[5]==s2[5]&&s1[6]==s2[4])printf("Equal\n");
else if(s1[1]==s2[3]&&s1[2]==s2[5]&&s1[3]==s2[6]&&s1[4]==s2[2]&&s1[5]==s2[4]&&s1[6]==s2[1])printf("Equal\n");
else if(s1[1]==s2[6]&&s1[2]==s2[4]&&s1[3]==s2[5]&&s1[4]==s2[2]&&s1[5]==s2[3]&&s1[6]==s2[1])printf("Equal\n");
else if(s1[1]==s2[5]&&s1[2]==s2[3]&&s1[3]==s2[4]&&s1[4]==s2[2]&&s1[5]==s2[6]&&s1[6]==s2[1])printf("Equal\n");
else if(s1[1]==s2[4]&&s1[2]==s2[6]&&s1[3]==s2[3]&&s1[4]==s2[2]&&s1[5]==s2[5]&&s1[6]==s2[1])printf("Equal\n");
else if(s1[1]==s2[3]&&s1[2]==s2[5]&&s1[3]==s2[4]&&s1[4]==s2[1]&&s1[5]==s2[6]&&s1[6]==s2[2])printf("Equal\n");
else if(s1[1]==s2[6]&&s1[2]==s2[4]&&s1[3]==s2[3]&&s1[4]==s2[1]&&s1[5]==s2[5]&&s1[6]==s2[2])printf("Equal\n");
else if(s1[1]==s2[5]&&s1[2]==s2[3]&&s1[3]==s2[6]&&s1[4]==s2[1]&&s1[5]==s2[4]&&s1[6]==s2[2])printf("Equal\n");
else if(s1[1]==s2[4]&&s1[2]==s2[6]&&s1[3]==s2[5]&&s1[4]==s2[1]&&s1[5]==s2[3]&&s1[6]==s2[2])printf("Equal\n");
else if(s1[1]==s2[4]&&s1[2]==s2[6]&&s1[3]==s2[1]&&s1[4]==s2[3]&&s1[5]==s2[2]&&s1[6]==s2[5])printf("Equal\n");
else if(s1[1]==s2[3]&&s1[2]==s2[5]&&s1[3]==s2[1]&&s1[4]==s2[6]&&s1[5]==s2[2]&&s1[6]==s2[4])printf("Equal\n");
else if(s1[1]==s2[6]&&s1[2]==s2[4]&&s1[3]==s2[1]&&s1[4]==s2[5]&&s1[5]==s2[2]&&s1[6]==s2[3])printf("Equal\n");
else if(s1[1]==s2[5]&&s1[2]==s2[3]&&s1[3]==s2[1]&&s1[4]==s2[4]&&s1[5]==s2[2]&&s1[6]==s2[6])printf("Equal\n");
else if(s1[1]==s2[5]&&s1[2]==s2[3]&&s1[3]==s2[2]&&s1[4]==s2[6]&&s1[5]==s2[1]&&s1[6]==s2[4])printf("Equal\n");
else if(s1[1]==s2[4]&&s1[2]==s2[6]&&s1[3]==s2[2]&&s1[4]==s2[5]&&s1[5]==s2[1]&&s1[6]==s2[3])printf("Equal\n");
else if(s1[1]==s2[3]&&s1[2]==s2[5]&&s1[3]==s2[2]&&s1[4]==s2[4]&&s1[5]==s2[1]&&s1[6]==s2[6])printf("Equal\n");
else if(s1[1]==s2[6]&&s1[2]==s2[4]&&s1[3]==s2[2]&&s1[4]==s2[3]&&s1[5]==s2[1]&&s1[6]==s2[5])printf("Equal\n");
else printf("Not Equal\n");
}
return 0;
}
brianfry713
Guru
Posts: 5947 Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA
Post
by brianfry713 » Fri Sep 07, 2012 12:38 am
That is AC code.
Check input and AC output for thousands of problems on
uDebug !
tzupengwang
New poster
Posts: 36 Joined: Fri Dec 02, 2011 1:30 pm
Location: Kaohsiung, Taiwan
Post
by tzupengwang » Fri Sep 07, 2012 6:02 am
Wow~I didn't notice that, maybe there's a problem about my submission, I got AC now!
forthright48
New poster
Posts: 37 Joined: Wed Mar 14, 2012 11:57 am
Location: Bangladesh
Contact:
Post
by forthright48 » Thu May 29, 2014 7:00 am
Tried really hard to avoid simulating rotation of the cube, but had no luck with mathematical approach
. So in the end, had to run flood-fill over all the states reachable from given string by simulating rotation to get AC.