Cursed Game
시간 제한2초메모리 제한1024 MB
333개의 라운드 각각에서 3x3 구멍 패턴으로 모든 결과가 1이 되는 흑백 NxN 격자를 찾아야 하며, 전체 질의는 999개로 제한된다.
문제
You found an antique box in your warehouse and decided to open it. The moment you open the box, it traps you into a cursed game where you are playing against a demon. The game consists of rounds and you have to win all rounds in order to escape. The demon also gives you coins that you can use throughout all rounds.
Note that in this problem, denote cell of a grid as the cell in row and column of the grid.
Before the start of each round, the demon will prepare a secret paper, which can be represented as a grid with rows and columns, both numbered from to . The demon will secretly put a hole in one or more cells, and you are not aware which cells have a hole in it. Then, the round starts with the demon giving you an odd integer ().
Within each round, you can ask the demon several queries, each costing you one coin. For each query, you are allowed to give the demon your paper, which can be represented as a grid with rows and columns, both numbered from to . Each cell is coloured either black or white by you.
For each of your query, the demon will calculate a binary result grid with rows and columns, both numbered from to . The value on cell of the result grid is filled as follows.
- The demon will put the secret paper on top of your paper such that the cell of your paper aligns with the cell of the secret paper, for .
- The demon can only see the colour of the cell in your paper if the corresponding cell in the secret paper has a hole in it.
- The value on cell of the result grid is if there is an odd number of black cells that it can see through the holes, or otherwise.
You win the round if the result grid consists of only the values . Otherwise, the demon will give you the result grid as a feedback, and the round continues.
If you have spent all the coins and still did not win all the rounds, then you will be trapped forever. Escape the cursed game!