static void Main(string[] args) { string[] inputs; inputs = Console.ReadLine().Split(' '); int P = int.Parse(inputs[0]); // number of players in the game (2 to 4 players) int ID = int.Parse(inputs[1]); // ID of your player (0, 1, 2, or 3) int D = int.Parse(inputs[2]); // number of drones in each team (3 to 11) int Z = int.Parse(inputs[3]); // number of zones on the map (4 to 8) //Zones int[][] zones = new int[Z][]; for (int i = 0; i < Z; i++) { inputs = Console.ReadLine().Split(' '); int X = int.Parse(inputs[0]); // corresponds to the position of the center of a zone. A zone is a circle with a radius of 100 units. int Y = int.Parse(inputs[1]); zones[i] = new int[3] { X, Y, 0 }; } //Zone HQ & Priority int HQ = Calcs.ZoneHQ(zones); int[] priority = new int[Z]; priority = Calcs.ZonePriority(HQ, zones); // Zone Distance Array double[] zoneDist = new double[Z]; for (int i = 0; i < Z; i++) { zoneDist[i] = Calcs.Distance(zones[HQ][0], zones[HQ][1], zones[i][0], zones[i][1]); } //Drones Drone[][] drones = new Drone[P][]; for (int i = 0; i < P; i++) { drones[i] = new Drone[D]; for (int j = 0; j < D; j++) { drones[i][j] = new Drone(); } } //Drone distances from HQ double[][] droneDist = new double[P][]; for (int i = 0; i < P; i++) { droneDist[i] = new double[D]; } // game loop while (true) { // List of who controls each zone by team ID for (int i = 0; i < Z; i++) { int TID = int.Parse(Console.ReadLine()); zones[i][2] = TID; } // Drone info for turn & update distances for (int i = 0; i < P; i++) { for (int j = 0; j < D; j++) { inputs = Console.ReadLine().Split(' '); int DX = int.Parse(inputs[0]); int DY = int.Parse(inputs[1]); drones[i][j].Update(DX, DY); droneDist[i][j] = Calcs.Distance(zones[HQ][0], zones[HQ][1], DX, DY); } Array.Sort(droneDist[i]); //Debug.DisplayDoubleArray(droneDist[i]); } // OUTPUT for (int i = 0; i < D; i++) { double targetDist = zoneDist[priority[priority.Length - 1]]; int targetZone = 0; // Check distance for (int j = 0; j < P; j++) { if (droneDist[j][i] < targetDist && j != ID) { targetDist = droneDist[j][i]; } } // Check for zone in distance for (int j = 0; j < Z; j++) { if (zoneDist[priority[j]] > targetDist) { break; } if (zones[priority[Math.Max(j - 1, 0)]][2] == ID) { targetZone = priority[j]; } else { targetZone = priority[Math.Max(j - 1, 0)]; } } Console.WriteLine(zones[targetZone][0] + " " + zones[targetZone][1]); } } }