## 11959 - Dice

Moderator: Board moderators

plamplam
Experienced poster
Posts: 150
Joined: Fri May 06, 2011 11:37 am

### 11959 - Dice

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

### Re: 11959 - Dice

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

### Re: 11959 - Dice

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

### Re: 11959 - Dice

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,s2;
int opp;

{
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--)
{
if (s1==s2&&s1==s2&&s1==s2&&s1==s2&&s1==s2&&s1==s2)printf("Equal\n");
else if(s1==s2&&s1==s2&&s1==s2&&s1==s2&&s1==s2&&s1==s2)printf("Equal\n");
else if(s1==s2&&s1==s2&&s1==s2&&s1==s2&&s1==s2&&s1==s2)printf("Equal\n");
else if(s1==s2&&s1==s2&&s1==s2&&s1==s2&&s1==s2&&s1==s2)printf("Equal\n");
else if(s1==s2&&s1==s2&&s1==s2&&s1==s2&&s1==s2&&s1==s2)printf("Equal\n");
else if(s1==s2&&s1==s2&&s1==s2&&s1==s2&&s1==s2&&s1==s2)printf("Equal\n");
else if(s1==s2&&s1==s2&&s1==s2&&s1==s2&&s1==s2&&s1==s2)printf("Equal\n");
else if(s1==s2&&s1==s2&&s1==s2&&s1==s2&&s1==s2&&s1==s2)printf("Equal\n");
else if(s1==s2&&s1==s2&&s1==s2&&s1==s2&&s1==s2&&s1==s2)printf("Equal\n");
else if(s1==s2&&s1==s2&&s1==s2&&s1==s2&&s1==s2&&s1==s2)printf("Equal\n");
else if(s1==s2&&s1==s2&&s1==s2&&s1==s2&&s1==s2&&s1==s2)printf("Equal\n");
else if(s1==s2&&s1==s2&&s1==s2&&s1==s2&&s1==s2&&s1==s2)printf("Equal\n");
else if(s1==s2&&s1==s2&&s1==s2&&s1==s2&&s1==s2&&s1==s2)printf("Equal\n");
else if(s1==s2&&s1==s2&&s1==s2&&s1==s2&&s1==s2&&s1==s2)printf("Equal\n");
else if(s1==s2&&s1==s2&&s1==s2&&s1==s2&&s1==s2&&s1==s2)printf("Equal\n");
else if(s1==s2&&s1==s2&&s1==s2&&s1==s2&&s1==s2&&s1==s2)printf("Equal\n");
else if(s1==s2&&s1==s2&&s1==s2&&s1==s2&&s1==s2&&s1==s2)printf("Equal\n");
else if(s1==s2&&s1==s2&&s1==s2&&s1==s2&&s1==s2&&s1==s2)printf("Equal\n");
else if(s1==s2&&s1==s2&&s1==s2&&s1==s2&&s1==s2&&s1==s2)printf("Equal\n");
else if(s1==s2&&s1==s2&&s1==s2&&s1==s2&&s1==s2&&s1==s2)printf("Equal\n");
else if(s1==s2&&s1==s2&&s1==s2&&s1==s2&&s1==s2&&s1==s2)printf("Equal\n");
else if(s1==s2&&s1==s2&&s1==s2&&s1==s2&&s1==s2&&s1==s2)printf("Equal\n");
else if(s1==s2&&s1==s2&&s1==s2&&s1==s2&&s1==s2&&s1==s2)printf("Equal\n");
else if(s1==s2&&s1==s2&&s1==s2&&s1==s2&&s1==s2&&s1==s2)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

### Re: 11959 - Dice

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

### Re: 11959 - Dice

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
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.