結果
問題 | No.94 圏外です。(EASY) |
ユーザー |
![]() |
提出日時 | 2014-12-20 10:02:48 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
CE
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 1,089 bytes |
コンパイル時間 | 1,051 ms |
コンパイル使用メモリ | 35,176 KB |
最終ジャッジ日時 | 2024-11-14 18:57:32 |
合計ジャッジ時間 | 1,771 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:71:38: error: ‘sqrt’ was not declared in this scope; did you mean ‘sqr’? 71 | ans = std::max( ans, sqrt(sqr(X[j]-X[i])+sqr(Y[j]-Y[i])) ); | ^~~~ | sqr main.cpp:52:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 52 | scanf( "%d", &N ); | ~~~~~^~~~~~~~~~~~ main.cpp:54:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 54 | scanf( "%d%d", X+i, Y+i ); | ~~~~~^~~~~~~~~~~~~~~~~~~~
ソースコード
#include<cstdio>#include<algorithm>#include<numeric>#include<vector>#define rep(i,a) for(int i=0;i<(a);++i)#define all(a) (a).begin(), (a).end()struct UnionFind{std::vector<int> par, rank;UnionFind( std::size_t sz ): par(sz), rank(sz){ std::iota( all(par), 0 ); }int find( int x ){ return x==par[x]?x:par[x]=find(par[x]); }void unite( int x, int y ){x = find(x);y = find(y);if( x == y )return;if( rank[x] < rank[y] )par[x] = y;else{par[y] = x;if( rank[x] == rank[y] )++rank[x];}return;}bool same( int x, int y ){ return find(x) == find(y); }};int N;int X[1000], Y[1000];int sqr( int x ){ return x*x; }int main(){scanf( "%d", &N );rep( i, N )scanf( "%d%d", X+i, Y+i );UnionFind uf( N );rep( i, N ){rep( j, i ){int d = sqr(X[j]-X[i])+sqr(Y[j]-Y[i]);if( d <= 100 )uf.unite( i, j );}}double ans = 0;rep( i, N ) rep( j, i ) if( uf.same( i, j ) )ans = std::max( ans, sqrt(sqr(X[j]-X[i])+sqr(Y[j]-Y[i])) );printf( "%.9f\n", N?ans+2:1 );return 0;}