Comments

For E1. we can enumerate the number of 0s as k and the number of 1s as p-i+1-k for the transition. Do I understand wrong. The code is enumerate k as number of 1s in [i, a[i]] interval rather than 0s?

Oh my bad thanks

Have a question about D1

3 2 3 3

for f(2) put mex(2,2,3,3) is 1 and put mex(1,2,3,3) is 4.Did I misunderstand the description?

Sorry, I am dumb in F what does the ans minus two values represent?