i am generating all the possible permutations and just checking whether any of them is possible or not !

i am getting WA in 2nd subtask can anyone please help me : https://www.codechef.com/viewsolution/15596784

i am generating all the possible permutations and just checking whether any of them is possible or not !

i am getting WA in 2nd subtask can anyone please help me : https://www.codechef.com/viewsolution/15596784

1 Like

You are doing a very silly error.

Check this input-

```
Input
1
6
1 2 3 4 5 6
Your Output
5 6 1 2 3 4
```

Now just tell me. The number opposite face 1 is 5. And the number opposite face 5 is 3.

This is wrong. If number opposite face 1 is 5, then number opposite face 5 must be 1. Even I did this mistake during contest and wasted a huuuuuge portion of my time

Kudos to @pk301 for pointing out about permutations! Thanks buddy

Can you explain the variables? And also how you are using a mask to generate all permutations?

True, just noticed hes using recursion for that, its just a modified version of generating all permutation. That case, will have to delve deeper into the code.

1 Like

that was really nice!! i really want to know what is wrong in this code ! thanks

@vijju123 can you suggest me another way of generating all the permutations(as you have written that it’s just a modified version!)?

You can use simple recursion to do the trick as well. Check out geeksforgeeks for that