Блог пользователя Herothenewdominator

Автор Herothenewdominator, история, 8 месяцев назад, По-английски

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://mirror.codeforces.com/contest/2116/submission/336427692

The problem https://mirror.codeforces.com/contest/2116/problem/B

  • Проголосовать: нравится
  • -2
  • Проголосовать: не нравится

»
8 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

This line" ll sum = max(raw1, raw2) % 998244353; might be the problem

I don't think you can just take the max of raw1 and raw2, because both of those values are the result of a MOD operation. Just consider this tiny example:
a = 17, b = 14, mod = 15
now a > b, but a % mod < b % mod

This example would fail in your code

»
8 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

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.