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

30909번 - Lateral Damage 다국어인터랙티브

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

문제

You are playing Battleships in a large ocean with large ships. More precisely, there is a large square grid of size at most 100ドル\times 100$ and inside it are up to 10ドル$ of the largest type of ship in Battleships -- the aircraft carrier -- which has a length of five tiles, placed either horizontally or vertically. The ships do not overlap, but they are allowed to be adjacent to each other. See Figure L.1 for an example.

Unfortunately, your opponent appears to bend the rules to their liking. It looks like they do not always determine the placement of their ships before you start shooting. You are not impressed by their attempt at cheating, and decide to try and win the game anyway.

Figure L.1: Illustration of Sample Interaction 1 after the first four shots were fired.

Your goal is to locate and sink all your opponent's aircraft carriers in at most 2500ドル$ shots, that is, you must hit each of the five tiles of all their ships.

입력

출력

제한

인터랙션

This is an interactive problem. Your submission will be run against an interactor, which reads from the standard output of your submission and writes to the standard input of your submission. This interaction needs to follow a specific protocol:

The interactor first sends one line with two integers $n$ and $k$ (5ドル \le n \le 100,ドル 1ドル \le k \le 10$), the size of the grid and the number of ships. It is guaranteed that it is possible to place $k$ aircraft carriers in the grid without overlap.

Then, your program needs to start firing shots. Each shot is fired by printing one line of the form "$x$ $y$" (1ドル \le x,y \le n$), indicating you shoot at position $(x, y)$. The interactor will respond with "hit" if the shot was a hit, "sunk" if the shot caused an aircraft carrier to sink, and "miss" otherwise. If you have shot the same location before, the response will be "miss".

Once you sink the last aircraft carrier, the interaction will stop and your program must exit.

The interactor is adaptive: the positions of the ships may be determined during the interaction, and may depend on where you decide to shoot.

Make sure you flush the buffer after each write.

A testing tool is provided to help you develop your solution.

Firing more than 2500ドル$ shots will result in a wrong answer.

예제 입력 1

7 2
miss
hit
miss
hit
hit
hit
hit
sunk
miss
miss
hit
miss
hit
hit
sunk

예제 출력 1

6 1
6 3
7 3
5 3
4 3
3 3
2 3
1 3
6 7
6 7
6 2
6 2
6 4
6 5
6 6

힌트

출처

ICPC > Regionals > Europe > Northwestern European Regional Contest > NWERC 2023 L번

채점 및 기타 정보

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

출처

대학교 대회

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

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