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








This line"
ll sum = max(raw1, raw2) % 998244353;might be the problemI 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
So what change are you suggesting me to do
Judging by your accepted submission, it seems like you already figured it out, nice!
No i didnt, i saw some solutions of my friends from them i copied this, still im not able to figure out why my code failed earlier, logic is absolutely correct
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.