結果
問題 | No.1265 Balloon Survival |
ユーザー |
![]() |
提出日時 | 2020-10-23 22:33:01 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 464 ms / 2,000 ms |
コード長 | 1,787 bytes |
コンパイル時間 | 2,952 ms |
コンパイル使用メモリ | 112,064 KB |
実行使用メモリ | 45,696 KB |
最終ジャッジ日時 | 2024-07-21 11:21:38 |
合計ジャッジ時間 | 9,761 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 32 |
コンパイルメッセージ
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; using System.Collections.Generic; using System.Linq; using System.Text; using Tiil = System.Tuple<int, int, long>; class TEST{ static void Main(){ Sol mySol =new Sol(); mySol.Solve(); } } class Sol{ public void Solve(){ List<Tiil> L = new List<Tiil>(); for(int i=0;i<N;i++){ for(int j=i+1;j<N;j++){ L.Add(new Tiil(i, j, (X[i] - X[j]) * (X[i] - X[j]) + (Y[i] - Y[j]) * (Y[i] - Y[j]))); } } L.Sort((p, q) => p.Item3.CompareTo(q.Item3)); int cnt = 0; bool[] disappear = new bool[N]; foreach(var p in L){ if(disappear[p.Item1] || disappear[p.Item2]) continue; if(p.Item1 != 0 && p.Item2 != 0){ disappear[p.Item1] = true; disappear[p.Item2] = true; continue; } if(p.Item1 == 0 && p.Item2 != 0){ disappear[p.Item2] = true; cnt++; continue; } if(p.Item1 != 0 && p.Item2 == 0){ disappear[p.Item1] = true; cnt++; continue; } } Console.WriteLine(cnt); } int N; long[] X,Y; public Sol(){ N = ri(); X = new long[N]; Y = new long[N]; for(int i=0;i<N;i++){ var d = ria(); X[i] = d[0]; Y[i] = d[1]; } } static String rs(){return Console.ReadLine();} static int ri(){return int.Parse(Console.ReadLine());} static long rl(){return long.Parse(Console.ReadLine());} static double rd(){return double.Parse(Console.ReadLine());} static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);} static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));} static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));} static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));} }