Cursed Game

시간 제한2초메모리 제한1024 MB

요약
333개의 라운드 각각에서 3x3 구멍 패턴으로 모든 결과가 1이 되는 흑백 NxN 격자를 찾아야 하며, 전체 질의는 999개로 제한된다.
난이도

어려움10점 중 8점

유형
수학, 완전 탐색, 비트 연산, 그리디
정답자
아직 제출이 없습니다

문제

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 333333 rounds and you have to win all rounds in order to escape. The demon also gives you 999999 coins that you can use throughout all rounds.

Note that in this problem, denote cell (r,c)(r, c) of a grid as the cell in row rr and column cc of the grid.

Before the start of each round, the demon will prepare a secret paper, which can be represented as a grid with 33 rows and 33 columns, both numbered from 11 to 33. 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 NN (3≤N≤333 ≤ N ≤ 33).

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 NN rows and NN columns, both numbered from 11 to NN. Each cell is coloured either black or white by you.

For each of your query, the demon will calculate a binary result grid with N−2N - 2 rows and N−2N - 2 columns, both numbered from 11 to N−2N - 2. The value on cell (r,c)(r, c) of the result grid is filled as follows.

  • The demon will put the secret paper on top of your paper such that the cell (r+i−1,c+j−1)(r + i - 1, c + j - 1) of your paper aligns with the cell (i,j)(i, j) of the secret paper, for 1≤i,j≤31 ≤ i, j ≤ 3.
  • 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 (r,c)(r, c) of the result grid is 11 if there is an odd number of black cells that it can see through the holes, or 00 otherwise.

You win the round if the result grid consists of only the values 11. 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!

예제1

  1. 예제 1

    입력
    3
    
    
    
    INCORRECT
    0
    
    
    
    CORRECT
    5
    
    
    
    
    
    INCORRECT
    111
    001
    111
    
    
    
    
    
    CORRECT
    (start of round 3, continue until 333 rounds)
    
    예상 출력
    
    111
    000
    111
    
    
    111
    111
    111
    
    
    10011
    10011
    00000
    11010
    11011
    
    
    
    
    11011
    11011
    00100
    11011
    11011