結果
| 問題 |
No.94 圏外です。(EASY)
|
| コンテスト | |
| ユーザー |
mban
|
| 提出日時 | 2017-04-11 15:01:28 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
AC
|
| 実行時間 | 48 ms / 5,000 ms |
| コード長 | 2,249 bytes |
| コンパイル時間 | 908 ms |
| コンパイル使用メモリ | 114,560 KB |
| 実行使用メモリ | 21,248 KB |
| 最終ジャッジ日時 | 2024-06-26 08:10:34 |
| 合計ジャッジ時間 | 2,436 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 22 |
コンパイルメッセージ
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 void Main(string[] args)
{
new Magatro().Solve();
}
}
public class Magatro
{
private int N;
P[] XY;
int[] Par;
List<int>[] List;
private void Scan()
{
N = int.Parse(Console.ReadLine());
XY = new P[N];
for (int i = 0; i < N; i++)
{
string[] s = Console.ReadLine().Split(' ');
XY[i] = new P(int.Parse(s[0]), int.Parse(s[1]));
}
}
private void Union(int a, int b)
{
a = Root(a);
b = Root(b);
if (a == b) return;
Par[b] = a;
foreach (int i in List[b])
{
List[a].Add(i);
}
}
private int Root(int a)
{
return Par[a] == a ? a : Root(Par[a]);
}
private bool Same(int a, int b)
{
return Root(a) == Root(b);
}
public void Solve()
{
Scan();
if( N == 0)
{
Console.WriteLine(1);
return;
}
Par = new int[N];
List = new List<int>[N];
for (int i = 0; i < N; i++)
{
Par[i] = i;
List[i] = new List<int>();
List[i].Add(i);
}
for (int i = 0; i < N - 1; i++)
{
for (int j = i + 1; j < N; j++)
{
if (Dist(XY[i], XY[j]) <= 10 * 10)
{
Union(i, j);
}
}
}
var hs = new HashSet<int>();
int ans = 0;
for (int i = 0; i < N; i++)
{
int j = Root(i);
if (!hs.Add(j)) continue ;
for (int k = 0; k < List[j].Count - 1; k++)
{
for (int l = k + 1; l < List[j].Count; l++)
{
ans = Math.Max(Dist(XY[List[j][k]], XY[List[j][l]]), ans);
}
}
}
Console.WriteLine(Math.Sqrt(ans) + 2);
}
public int Dist(P a, P b)
{
return (a.X - b.X) * (a.X - b.X) + (a.Y - b.Y) * (a.Y - b.Y);
}
}
public struct P
{
public int X, Y;
public P(int x, int y)
{
X = x;
Y = y;
}
}
mban