結果
| 問題 |
No.168 ものさし
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2015-03-20 02:31:05 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 124 ms / 2,000 ms |
| コード長 | 1,057 bytes |
| コンパイル時間 | 627 ms |
| コンパイル使用メモリ | 55,532 KB |
| 実行使用メモリ | 26,624 KB |
| 最終ジャッジ日時 | 2024-12-24 07:01:59 |
| 合計ジャッジ時間 | 2,422 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 19 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:23:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
23 | scanf("%d",&N);
| ~~~~~^~~~~~~~~
main.cpp:27:42: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
27 | for(int i=0;i<N;i++)scanf("%lld%lld",&V[i].first,&V[i].second);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ソースコード
//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));
}