I solved this problem using bitsets in O(N + 32), i.e. O(N) time complexity. Here is my solution .

click here

can anyone help me I am getting WA in task #2 and #5 my solution is working fine on all the cases I tried thanks in advance. #help

https://www.codechef.com/viewsolution/40453822

1 Like

Code chef must provide more input test cases in questions to understand questions more clearly and it will help us figure out approach more effectively

1 Like

## n = 3 & x = 8

63 70 19

ans acc. to editorial soln: 0 0 106

```
x | p | i | j | seq |
1: p = 5 , i = 0 , j = 2 => 31 70 51(19+32)
2: p = 4 , i = 0 , j = 2 => 15 70 35(51-16 = 35)
3: p = 3 , i = 0 , j = 2 => 07 70 43(51-16+8 = 43)
4: p = 2 , i = 0 , j = 1 => 03 66(70-4) 43
5: p = 1 , i = 0 , j = 1 => 01 64(70-4-2) 43
6: p = 0 , i = 0 , j = 2 => 00 64 42(43 - 1 = 42)
7: p = 6 , i = 1 , j = 2 => 00 00 106(43 - 1 + 64 = 106)
```

here it left one operation??

so when left opertion is odd and n > 2 then what will be the correct ans?

ans should be : 0 1 107??

what a garbage problem this is …

worst ever