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

25363번 - Interactive Treasure Hunt 다국어인터랙티브

시간 제한메모리 제한제출정답맞힌 사람정답 비율
3 초 512 MB140484434.109%

문제

This is an interactive problem.

There is a grid of $n\times m$ cells. Two treasure chests are buried in two different cells of the grid. Your task is to find both of them. You can make two types of operations:

  • DIG $r$ $c$: try to find the treasure in the cell $(r, c)$. The interactor will tell you if you found the treasure or not.
  • SCAN $r$ $c$: scan from the cell $(r, c)$. The result of this operation is the sum of Manhattan distances from the cell $(r, c)$ to the cells where the treasures are hidden. Manhattan distance from a cell $(r_1, c_1)$ to a cell $(r_2, c_2)$ is calculated as $|r_1 - r_2| + |c_1 - c_2|$.

You need to find the treasures in at most 7 operations. This includes both DIG and SCAN operations in total. To solve the test you need to call DIG operation at least once in both of the cells where the treasures are hidden.

입력

출력

제한

인터랙션

Your program has to process multiple test cases in a single run. First, the testing system writes $t$ --- the number of test cases (1ドル\le t \le 100$). Then, $t$ test cases should be processed one by one.

In each test case, your program should start by reading the integers $n$ and $m$ (2ドル \le n, m \le 16$).

Then, your program can make queries of two types:

  • DIG $r$ $c$ (1ドル\le r\le n$; 1ドル\le c\le m$). The interactor responds with integer 1ドル,ドル if you found the treasure, and 0ドル$ if not. If you try to find the treasure in the same cell multiple times, the result will be 0ドル$ since the treasure is already found.
  • SCAN $r$ $c$ (1ドル\le r\le n$; 1ドル\le c\le m$). The interactor responds with an integer that is the sum of Manhattan distances from the cell $(r, c)$ to the cells where the treasures were hidden. The sum is calculated for both cells with treasures, even if you already found one of them.

After you found both treasures, i. e. you received 1ドル$ for two DIG operations, your program should continue to the next test case or exit if that test case was the last one.

예제 입력 1

1
2 3
1
1
3
0
1

예제 출력 1

SCAN 1 2
DIG 1 2
SCAN 2 2
DIG 1 1
DIG 1 3

힌트

출처

ICPC > Regionals > Northern Eurasia > Northern Eurasia Finals > Northern Eurasia Finals 2021 I번

채점 및 기타 정보

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

출처

대학교 대회

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

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