結果
問題 | No.168 ものさし |
ユーザー |
|
提出日時 | 2015-03-20 02:06:06 |
言語 | C++11 (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 999 bytes |
コンパイル時間 | 536 ms |
コンパイル使用メモリ | 54,784 KB |
実行使用メモリ | 26,624 KB |
最終ジャッジ日時 | 2024-06-28 23:40:21 |
合計ジャッジ時間 | 2,203 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | WA * 4 |
other | WA * 19 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:19:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 19 | scanf("%d",&N); | ~~~~~^~~~~~~~~ main.cpp:23:42: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 23 | 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 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)); }