Logo
(追記) (追記ここまで)

25768번 - Battleship: New Rules 다국어인터랙티브

시간 제한메모리 제한제출정답맞힌 사람정답 비율
3 초 (추가 시간 없음) 1024 MB1000.000%

문제

This is an interactive problem.

Ivan came up with new rules for the battleship game!

  • The game will be played on an $n \times n$ board.
  • The first player chooses an integer $k$ ($n \leq k \leq {\left\lceil \frac{n}{2} \right\rceil}^2$).
  • After that, the first player places $k$ ships on the board so that the number of cells occupied by the ships is the maximum possible (among all valid placements of $k$ ships of any sizes).
  • Each ship should be a rectangle of size 1ドル \times a$ or $a \times 1$ ($a$ is any integer from 1ドル$ to $n$ inclusive). Any two ships should not have neighbouring cells (by side or by corner).

After that, the second player starts his game.

  • The second player knows only the size of the board $n$.
  • The second player can ask a query: is cell $(x, y)$ occupied by some ship?
  • The second player should find any empty 2ドル \times 2$ square on the board, or say that there are no such squares.

The second player can ask at most 6ドルn$ queries. Please play as the second player and win the game!

입력

출력

제한

인터랙션

The first line contains a single integer $t$ (1ドル \leq t \leq 100$) --- the number of games to be played. You should play $t$ games and finish interaction after that.

At the start of the game, you are given a single integer $n$ (3ドル \leq n \leq 1000$) --- the size of the board.

After that, you can ask some queries. To ask a query, print a single line "? $x$ $y$" (1ドル \leq x, y \leq n$) --- the coordinates of the cell. You will be given an answer $c$:

  • If $c = -1,ドル you made too many queries. You should terminate your program.
  • If $c = 0,ドル the cell $(x, y)$ is empty.
  • If $c = 1,ドル the cell $(x, y)$ is occupied by some ship.

To finish the game, print a single line "! $x$ $y$", where:

  • $x=-1,ドル $y=-1$ if there are no empty 2ドル \times 2$ squares on the board.
  • Otherwise, 1ドル \leq x, y \leq n - 1$ and the square with cells $(x, y),ドル $(x+1, y),ドル $(x, y+1),ドル $(x+1, y+1)$ is empty.

If your answer is incorrect, you will be given a line with value -1, and you should terminate your program. Otherwise, you will be given a line with value 1, and you should play the next game (or finish your program if it was the last game).

It is guaranteed that the sum of $n$ for all games does not exceed 5000ドル$.

It is guaranteed that the board in each game is fixed, and the interactor is not adaptive.

Your solution will get Time Limit Exceeded if you don't print anything or forget to flush the output.

예제 입력 1

2
3
0
1
4
0
1
1

예제 출력 1

? 2 1
! -1 -1
? 1 3
? 4 3
! 2 2

힌트

Boards from the first test are shown on pictures below. Rows correspond to $x$ coordinates, columns correspond to $y$ coordinates.

Board from the first game. Board from the second game.

출처

Camp > Petrozavodsk Programming Camp > Summer 2022 > Day 7: HSE Koresha Contest G번

채점 및 기타 정보

  • 예제는 채점하지 않는다.
(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /