結果
| 問題 |
No.94 圏外です。(EASY)
|
| コンテスト | |
| ユーザー |
hogeover30
|
| 提出日時 | 2015-03-12 03:16:11 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
CE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 935 bytes |
| コンパイル時間 | 405 ms |
| コンパイル使用メモリ | 56,104 KB |
| 最終ジャッジ日時 | 2024-11-14 19:00:44 |
| 合計ジャッジ時間 | 792 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:17:9: error: ‘vector’ was not declared in this scope
17 | vector<int> x(n), y(n);
| ^~~~~~
main.cpp:5:1: note: ‘std::vector’ is defined in header ‘<vector>’; did you forget to ‘#include <vector>’?
4 | #include <cmath>
+++ |+#include <vector>
5 | using namespace std;
main.cpp:17:16: error: expected primary-expression before ‘int’
17 | vector<int> x(n), y(n);
| ^~~
main.cpp:18:35: error: ‘x’ was not declared in this scope
18 | for(int i=0;i<n;++i) cin>>x[i]>>y[i];
| ^
main.cpp:18:41: error: ‘y’ was not declared in this scope
18 | for(int i=0;i<n;++i) cin>>x[i]>>y[i];
| ^
main.cpp:22:23: error: ‘x’ was not declared in this scope
22 | if (dist2(x[i], y[i], x[j], y[j])<=100) unite(i, j);
| ^
main.cpp:22:29: error: ‘y’ was not declared in this scope
22 | if (dist2(x[i], y[i], x[j], y[j])<=100) unite(i, j);
| ^
main.cpp:28:32: error: ‘x’ was not declared in this scope
28 | d=max(d, dist2(x[i], y[i], x[j], y[j]));
| ^
main.cpp:28:38: error: ‘y’ was not declared in this scope
28 | d=max(d, dist2(x[i], y[i], x[j], y[j]));
| ^
ソースコード
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
using namespace std;
int id[1010];
int root(int x) { return id[x]!=x ? id[x]=root(id[x]) : x; }
void unite(int x, int y) { x=root(x); y=root(y); id[x]=y; }
bool same(int x, int y) { return root(x)==root(y); }
int dist2(int x, int y, int a, int b) { return (x-a)*(x-a)+(y-b)*(y-b); }
int main()
{
int n;
while (cin>>n) {
vector<int> x(n), y(n);
for(int i=0;i<n;++i) cin>>x[i]>>y[i];
for(int i=0;i<n;++i) id[i]=i;
for(int i=0;i<n;++i) for(int j=0;j<n;++j) if (i!=j)
if (dist2(x[i], y[i], x[j], y[j])<=100) unite(i, j);
int maxd=0;
for(int i=0;i<n;++i) {
int d=0;
for(int j=0;j<n;++j) if (i!=j and same(i, j))
d=max(d, dist2(x[i], y[i], x[j], y[j]));
maxd=max(maxd, d);
}
printf("%.10f\n", n ? sqrt(maxd)+2 : 1);
}
}
hogeover30