using System; using System.Collections.Generic; class Program { static HashSet alreadyFired = new HashSet(); static Random rng = new Random(); static void Main() { string? line; while ((line = Console.ReadLine()) != null) { // GAME STARTED → place ships if (line.StartsWith("GAME STARTED")) { Console.WriteLine("PLACE B A1 N"); Console.WriteLine("PLACE B C1 N"); Console.WriteLine("PLACE C E1 N"); Console.WriteLine("PLACE D G1 N"); Console.WriteLine("PLACE D I1 N"); Console.WriteLine("PLACE P A7 D"); Console.WriteLine("PLACE P A9 D"); Console.WriteLine("PLACE P H8 N"); Console.WriteLine("READY"); } // YOUR TURN → fire randomly if (line.StartsWith("YOUR TURN")) { string pos; do { int row = rng.Next(1, 11); // 1–10 char rowChar = (char)('A' + row - 1); int col = rng.Next(1, 11); // 1–10 pos = $"{rowChar}{col}"; } while (alreadyFired.Contains(pos)); Console.WriteLine($"FIRE {pos}"); alreadyFired.Add(pos); } // GAME OVER → exit if (line.StartsWith("GAME OVER")) { return; } } } }