Page **1** of **1**

### 11959 - Dice

Posted: **Sun Jul 03, 2011 3:36 pm**

by **plamplam**

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

### Re: 11959 - Dice

Posted: **Tue Jul 05, 2011 10:34 pm**

by **yeasin_acm_solver**

i can't understand this input output case :

input:

1

123456 461325

output:

Equal

Can anyone help me by explain how it is possible ?

### Re: 11959 - Dice

Posted: **Wed Jul 06, 2011 8:09 pm**

by **plamplam**

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

### Re: 11959 - Dice

Posted: **Thu Sep 06, 2012 2:19 pm**

by **tzupengwang**

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;
}
```

### Re: 11959 - Dice

Posted: **Fri Sep 07, 2012 12:38 am**

by **brianfry713**

That is AC code.

### Re: 11959 - Dice

Posted: **Fri Sep 07, 2012 6:02 am**

by **tzupengwang**

Wow~I didn't notice that, maybe there's a problem about my submission, I got AC now!

### Re: 11959 - Dice

Posted: **Thu May 29, 2014 7:00 am**

by **forthright48**

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.