結果
問題 |
No.2923 Mayor's Job
|
ユーザー |
![]() |
提出日時 | 2025-02-11 15:06:04 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 107 ms / 2,000 ms |
コード長 | 3,535 bytes |
コンパイル時間 | 6,065 ms |
コンパイル使用メモリ | 117,660 KB |
実行使用メモリ | 28,596 KB |
最終ジャッジ日時 | 2025-02-11 15:06:14 |
合計ジャッジ時間 | 7,741 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 17 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System; using System.Collections.Generic; using System.Linq; class Program { static string InputPattern = "InputX"; static List<string> GetInputList() { var WillReturn = new List<string>(); if (InputPattern == "Input1") { WillReturn.Add("4 2"); WillReturn.Add("13 7 2 16"); WillReturn.Add("1 1"); WillReturn.Add("1 3"); WillReturn.Add("2 4"); WillReturn.Add("11 10"); } else if (InputPattern == "Input2") { WillReturn.Add("3 2"); WillReturn.Add("1 2 2"); WillReturn.Add("1 1"); WillReturn.Add("1 1"); WillReturn.Add("1 3"); } else if (InputPattern == "Input3") { WillReturn.Add("19 8"); WillReturn.Add("70 90 200 93 73 47 87 115 193 102 50 47 146 11 134 178 175 185 41"); WillReturn.Add("13 10"); WillReturn.Add("20 13"); WillReturn.Add("15 29"); WillReturn.Add("23 27"); WillReturn.Add("25 17"); WillReturn.Add("20 12"); WillReturn.Add("11 27"); WillReturn.Add("16 12"); WillReturn.Add("16 26"); WillReturn.Add("18 14"); WillReturn.Add("14 2"); WillReturn.Add("9 6"); WillReturn.Add("15 5"); WillReturn.Add("22 1"); WillReturn.Add("11 22"); WillReturn.Add("14 20"); WillReturn.Add("19 18"); WillReturn.Add("30 18"); WillReturn.Add("18 24"); } else { string wkStr; while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr); } return WillReturn; } struct ObjectInfoDef { internal long X; internal long Y; internal long History; } static List<ObjectInfoDef> mObjectInfoList = new List<ObjectInfoDef>(); static void Main() { List<string> InputList = GetInputList(); long[] wkArr = { }; Action<string> SplitAct = pStr => wkArr = pStr.Split(' ').Select(pX => long.Parse(pX)).ToArray(); SplitAct(InputList[0]); long K = wkArr[1]; long[] HArr = InputList[1].Split(' ').Select(pX => long.Parse(pX)).ToArray(); long ObjectID = 0; foreach (string EachStr in InputList.Skip(2)) { SplitAct(EachStr); ObjectInfoDef WillAdd; WillAdd.X = wkArr[0]; WillAdd.Y = wkArr[1]; WillAdd.History = HArr[ObjectID]; mObjectInfoList.Add(WillAdd); ObjectID++; } mObjectInfoList = mObjectInfoList.OrderBy(pX => pX.History).ToList(); long RemoveCnt = 0; for (int I = 0; I <= mObjectInfoList.Count - 1; I++) { for (int J = I + 1; J <= mObjectInfoList.Count - 1; J++) { if (mObjectInfoList[I].History == mObjectInfoList[J].History) { continue; } long DiffX = mObjectInfoList[I].X - mObjectInfoList[J].X; long DiffY = mObjectInfoList[I].Y - mObjectInfoList[J].Y; long Norm = DiffX * DiffX + DiffY * DiffY; if (Norm <= K * K) { //Console.WriteLine("I={0},J={1}で削除", I, J); RemoveCnt++; break; } } } Console.WriteLine(mObjectInfoList.Count - RemoveCnt); } }