Is it just me or is the time constraint incorrect in this problem? If the authoring works for 1c, I would very much like to see the authoring solution, if someone answers me here, I would be very happy)
qwertysun Hi, the time limit seems to be correct. We have a solution with 381 ms of execution time, so it's quite solvable.
Time complexity of the mentioned solution is O(S•(N+M)•log(N+M)). While I could send you a link, I think you could solve it by your own :)