Under construction

Still being built. Things may change

Lateral Damage

Time limit2sMemory limit1024 MB

Summary
Locate and sink all up to ten hidden aircraft carriers (length 5 each) on a grid of at most 100 by 100 using at most 2500 shots.
Level

Medium6 of 10

Topics
Simulation, Greedy, Implementation
Solved
No attempts yet

Problem

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

Figure L.1: The board after the first four shots.

Your opponent appears to bend the rules to their liking. They do not always fix the placement of their ships before you start shooting. You are not impressed by this attempt at cheating, so you decide to win the game anyway.

Your goal is to locate and sink all of your opponent's aircraft carriers in at most 25002500 shots. You must hit each of the five tiles of all their ships.

Examples1

  1. Example 1

    Input
    7 2
    
    miss
    
    hit
    
    miss
    
    hit
    
    hit
    
    hit
    
    hit
    
    sunk
    
    miss
    
    miss
    
    hit
    
    miss
    
    hit
    
    hit
    
    sunk
    
    Expected output
    
    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