Codeforces Round 1133 (Div. 1, Div. 2) is coming soon! Register here. ×

Herothenewdominator's blog

By Herothenewdominator, history, 14 months ago, In English

Can anyone plese help me out what is the issue in my code, just couldnt understand why is it giving wrong answer for this, logic seems to be correct I guess

My submission https://codeforces.me/contest/2116/submission/336427692

The problem https://codeforces.me/contest/2116/problem/B

  • Vote: I like it
  • -2
  • Vote: I do not like it

| Write comment?
»
14 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Don't compare numbers after taking modulo, compare them before taking modulo.

In this case, it's 2^i+2^j versus 2^x+2^y. Compare them lexicographically to see which number is bigger, then and only then take modulo.