結果
問題 | No.168 ものさし |
ユーザー | ciel |
提出日時 | 2015-03-20 02:31:05 |
言語 | C++11 (gcc 11.4.0) |
結果 |
AC
|
実行時間 | 119 ms / 2,000 ms |
コード長 | 1,057 bytes |
コンパイル時間 | 582 ms |
コンパイル使用メモリ | 55,672 KB |
実行使用メモリ | 27,628 KB |
最終ジャッジ日時 | 2023-08-25 20:48:49 |
合計ジャッジ時間 | 2,434 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 28 ms
15,264 KB |
testcase_01 | AC | 2 ms
9,112 KB |
testcase_02 | AC | 3 ms
9,092 KB |
testcase_03 | AC | 3 ms
9,176 KB |
testcase_04 | AC | 3 ms
9,176 KB |
testcase_05 | AC | 2 ms
9,148 KB |
testcase_06 | AC | 3 ms
9,096 KB |
testcase_07 | AC | 3 ms
9,112 KB |
testcase_08 | AC | 3 ms
9,152 KB |
testcase_09 | AC | 3 ms
9,216 KB |
testcase_10 | AC | 5 ms
9,524 KB |
testcase_11 | AC | 26 ms
15,304 KB |
testcase_12 | AC | 82 ms
25,580 KB |
testcase_13 | AC | 117 ms
27,604 KB |
testcase_14 | AC | 119 ms
27,588 KB |
testcase_15 | AC | 2 ms
9,120 KB |
testcase_16 | AC | 3 ms
9,232 KB |
testcase_17 | AC | 4 ms
9,376 KB |
testcase_18 | AC | 8 ms
9,868 KB |
testcase_19 | AC | 114 ms
27,572 KB |
testcase_20 | AC | 116 ms
27,624 KB |
testcase_21 | AC | 118 ms
27,600 KB |
testcase_22 | AC | 118 ms
27,628 KB |
ソースコード
//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<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*/!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)); }