1217 F — DCP with offline sqrt decomposition — 60316117. Note — This is not very effecient code, I used dfs instead for rollbacks. For segtree solution check blog by adamant, it contains implementation by inventor of that technique or check this blog https://codeforces.com/blog/entry/65629.
For problem 100551A make sure that I/O is via files.
1217 F — DCP with offline sqrt decomposition — 60316117. Note — This is not very effecient code, I used dfs instead for rollbacks. For segtree solution check blog by adamant, it contains implementation by inventor of that technique or check this blog https://codeforces.com/blog/entry/65629.
For problem 100551A make sure that I/O is via files.