結果

問題 No.168 ものさし
ユーザー cielciel
提出日時 2015-03-20 02:06:06
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 999 bytes
コンパイル時間 503 ms
コンパイル使用メモリ 55,684 KB
実行使用メモリ 27,704 KB
最終ジャッジ日時 2023-09-11 09:00:06
合計ジャッジ時間 2,404 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
権限があれば一括ダウンロードができます

ソースコード

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 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<vector<long long> >v(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;i++)if(unite(a[node[i].second],b[node[i].second]))ret=max(ret,node[i].first),q++;
	printf("%lld\n",ret);
	printf("%.0Lf0\n",ceill(sqrtl(ret)/10));
}
0