CHEFFILT - Editorial

In editorialist’s solution why is there condition (if j<=j^i )in second loop of calculation of do solution?

The line that follows that tries to perform two operations at once:

“new_v[j] = (v[j] + v[j^i]) * p2[c[i]-1] mod" and "new_v[j^i] = (v[j] + v[j^i]) * p2[c[i]-1] mod”

This assigns the same value to two indices: j and j^i. However, without “j <= (j^i)”, this will be done twice (once for j and another for j^i), so the answer will be incorrect. We need “j <= (j^i)” for this to be only done once.

The Problem Setter’s solution is not available. Could someone please help me with that. Thank you.

Why does my solution get a WA verdict? Also, why does it TLE in the last subtask?

My Solution

Complexity: O(1024*1024)

Thanks in Advance!

i think its because of using maps…