Editorial for DMOPC '17 Contest 1 P1 - Fujō Neko


Remember to use this editorial only when stuck, and not to copy-paste code from it. Please be respectful to the problem author and editorialist.
Submitting an official solution before solving the problem yourself is a bannable offence.

Author: Kirito

For the first subtask, we can loop through the column xi and row yi and check if there's an X.

Time Complexity: O(RC+Q(R+C))

For the second subtask, we can preprocess the grid and create two arrays, A and B. Let Ai be true if there is an X on column i and Bj be true if there is an X on row j. To answer each query, we just check if Axi or Byi is true.

Time Complexity: O(RC+Q)


Comments

There are no comments at the moment.