結果

問題 No.94 圏外です。(EASY)
ユーザー kuuso1kuuso1
提出日時 2014-12-07 21:20:28
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 2,174 bytes
コンパイル時間 4,702 ms
コンパイル使用メモリ 107,356 KB
実行使用メモリ 26,168 KB
最終ジャッジ日時 2023-09-02 10:38:19
合計ジャッジ時間 5,782 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 62 ms
22,684 KB
testcase_01 AC 62 ms
22,656 KB
testcase_02 AC 64 ms
22,772 KB
testcase_03 WA -
testcase_04 AC 65 ms
24,684 KB
testcase_05 AC 66 ms
22,700 KB
testcase_06 AC 67 ms
22,592 KB
testcase_07 AC 71 ms
24,752 KB
testcase_08 AC 76 ms
22,668 KB
testcase_09 AC 87 ms
24,708 KB
testcase_10 AC 85 ms
22,668 KB
testcase_11 AC 86 ms
22,676 KB
testcase_12 AC 86 ms
22,652 KB
testcase_13 AC 87 ms
22,632 KB
testcase_14 AC 87 ms
22,656 KB
testcase_15 AC 88 ms
22,840 KB
testcase_16 AC 87 ms
22,728 KB
testcase_17 AC 86 ms
22,728 KB
testcase_18 AC 85 ms
24,808 KB
testcase_19 AC 95 ms
26,168 KB
testcase_20 AC 65 ms
24,740 KB
testcase_21 AC 64 ms
24,840 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using System.Collections;
using System.Collections.Generic;
 
class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		UnionFind UF=new UnionFind(N);
		for(int i=0;i<N;i++){
			for(int j=0;j<N;j++){
				if((X[i]-X[j])*(X[i]-X[j])+(Y[i]-Y[j])*(Y[i]-Y[j])<=100)UF.Union(i,j);
			}
		}
		
		List<int> D=new List<int>();
		for(int i=0;i<N;i++){
			for(int j=i+1;j<N;j++){
				if(UF.areSameGp(i,j))D.Add((X[i]-X[j])*(X[i]-X[j])+(Y[i]-Y[j])*(Y[i]-Y[j]));
			}
		}
		
		int max=0;
		for(int i=0;i<D.Count;i++){
			max=Math.Max(max,D[i]);
		}
		Console.WriteLine(2+Math.Sqrt(max));
		
		
	}
	int N;
	int[] X;
	int[] Y;
	public Sol(){
		N=ri();
		X=new int[N];
		Y=new int[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(){return Console.ReadLine().Split(' ');}
	static int[] ria(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>int.Parse(e));}
	static long[] rla(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>long.Parse(e));}
	static double[] rda(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>double.Parse(e));}
}

class UnionFind{
	int[] parent;
	int N;
	public UnionFind(int n_){
		Initialize(n_);
	}
	
	public void Initialize(int n_){
		N=n_;
		parent=new int[N];
		for(int i=0;i<N;i++)parent[i]=i;
	}
	
	public int Parent(int a){
		if(parent[a]==a)return a;
		return parent[a]=Parent(parent[a]);
	}
	
	public bool areSameGp(int a,int b){
		return Parent(a)==Parent(b);
	}
	
	public void Union(int a,int b){
		a=Parent(a);b=Parent(b);//Parent()を呼ぶことでa以上のノードは全てparentがrootになる
		if(a==b)return;
		parent[a]=b;
	}
	
	
	public void Dump(){
		for(int i=0;i<parent.Length;i++){
			Console.Write(i==0?"{0}":" {0}",parent[i]);
		}
		Console.WriteLine("");
	}
	
}
0