Hi. I am having problem trying to solve the last subtask for JNOI 2013/2914 — Historical Research. The english problem statement can be found here.
For those who can read Japanese, the editorial can be found here
The input and output data can be found here
My approach is as follows:
Perform square root decomposition on the queries by reordering them by their