結果
| 問題 |
No.1265 Balloon Survival
|
| コンテスト | |
| ユーザー |
keymoon
|
| 提出日時 | 2020-10-23 23:42:10 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
AC
|
| 実行時間 | 475 ms / 2,000 ms |
| コード長 | 1,295 bytes |
| コンパイル時間 | 2,149 ms |
| コンパイル使用メモリ | 112,984 KB |
| 実行使用メモリ | 46,208 KB |
| 最終ジャッジ日時 | 2024-07-21 13:42:36 |
| 合計ジャッジ時間 | 9,358 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.Data.SqlTypes;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
public static class P
{
public static void Main()
{
int n = int.Parse(Console.ReadLine());
long[][] pts = Enumerable.Repeat(0, n).Select(_ => Console.ReadLine().Split().Select(long.Parse).ToArray()).ToArray();
int res = 0;
HashSet<int> remain = new HashSet<int>(Enumerable.Range(0, n));
foreach (var item in Enumerable.Range(0, n - 1).SelectMany(x => Enumerable.Range(x + 1, n - x - 1).Select(y => new Tuple<int, int>(x, y))).OrderBy(x => GetDist(pts[x.Item1], pts[x.Item2])))
{
var i = item.Item1;
var j = item.Item2;
if (remain.Contains(i) && remain.Contains(j))
{
if (i != 0) remain.Remove(i);
else res++;
remain.Remove(j);
}
}
Console.WriteLine(res);
}
static long GetDist(long[] a, long[] b)
{
var dy = a[0] - b[0];
var dx = a[1] - b[1];
return dy * dy + dx * dx;
}
}
keymoon