結果

問題 No.168 ものさし
ユーザー cielciel
提出日時 2015-03-20 02:33:34
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 117 ms / 2,000 ms
コード長 1,024 bytes
コンパイル時間 610 ms
コンパイル使用メモリ 53,288 KB
実行使用メモリ 27,608 KB
最終ジャッジ日時 2023-08-25 20:48:52
合計ジャッジ時間 2,274 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
15,276 KB
testcase_01 AC 3 ms
9,156 KB
testcase_02 AC 3 ms
9,112 KB
testcase_03 AC 3 ms
9,136 KB
testcase_04 AC 3 ms
9,180 KB
testcase_05 AC 2 ms
9,140 KB
testcase_06 AC 2 ms
9,164 KB
testcase_07 AC 3 ms
9,196 KB
testcase_08 AC 3 ms
9,136 KB
testcase_09 AC 3 ms
9,236 KB
testcase_10 AC 5 ms
9,580 KB
testcase_11 AC 25 ms
15,280 KB
testcase_12 AC 80 ms
25,524 KB
testcase_13 AC 115 ms
27,580 KB
testcase_14 AC 115 ms
27,608 KB
testcase_15 AC 2 ms
9,184 KB
testcase_16 AC 3 ms
9,200 KB
testcase_17 AC 4 ms
9,408 KB
testcase_18 AC 7 ms
9,912 KB
testcase_19 AC 110 ms
27,528 KB
testcase_20 AC 116 ms
27,544 KB
testcase_21 AC 116 ms
27,568 KB
testcase_22 AC 117 ms
27,548 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

//kruskal tree
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
using namespace std;
#define M 1000000
int parent[M],a[M],b[M];
pair<long long,int>node[M];
int root(int a){return parent[a]==a?a:parent[a]=root(parent[a]);}
int same(int a,int b){
	int x=root(a),y=root(b);
	return x==y;
}
int unite(int a,int b){
	int x=root(a),y=root(b);
	if(x==y)return 0;
	parent[x]=y;
	return 1;
}
int main(){
	int N;
	scanf("%d",&N);
	{
		vector<pair<long long,long long> >V(N);
		for(int i=0;i<N;i++)scanf("%lld%lld",&V[i].first,&V[i].second);
		for(int i=0;i<N;i++){
			parent[i]=i;
			for(int j=0;j<N;j++){
				a[i*N+j]=i;
				b[i*N+j]=j;
				node[i*N+j].first=(V[i].first-V[j].first)*(V[i].first-V[j].first) + (V[i].second-V[j].second)*(V[i].second-V[j].second);
				node[i*N+j].second=i*N+j;
			}
		}
	}
	sort(node,node+N*N);
	long long ret=0;
	for(int q=0,i=0;/*q<N-1*/!same(0,N-1);i++)if(unite(a[node[i].second],b[node[i].second]))ret=max(ret,node[i].first),q++;
	printf("%.0Lf0\n",ceill(sqrtl(ret)/10));
}
0