結果
| 問題 |
No.94 圏外です。(EASY)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-12-18 16:40:01 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 5 ms / 5,000 ms |
| コード長 | 1,428 bytes |
| コンパイル時間 | 601 ms |
| コンパイル使用メモリ | 66,004 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-06-26 08:06:43 |
| 合計ジャッジ時間 | 1,376 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 22 |
ソースコード
#include <iostream>
#include <cmath>
#include <vector>
#include <cstdio>
using namespace std;
class Pos {
public:
int x;
int y;
Pos() {
}
Pos(int x, int y) {
this->x = x;
this->y = y;
}
int distance(Pos pos) {
return (x - pos.x) * (x - pos.x) + (y - pos.y) * (y - pos.y);
}
};
bool check[1000];
Pos all_pos[1000];
int N;
void foo(int index, vector<Pos> &poss) {
for (int i = 0; i < N; i++) {
if (check[i]) {
continue;
}
int distance = all_pos[index].distance(all_pos[i]);
if (distance <= 100) {
check[i] = true;
poss.push_back(all_pos[i]);
foo(i, poss);
}
}
}
int main() {
cin >> N;
for (int i = 0; i < N; i++) {
check[i] = false;
}
if (N == 0) {
cout << 1 << endl;
return 0;
}
int ans = 0;
for (int i = 0; i < N; i++) {
int x, y;
cin >> x >> y;
all_pos[i] = Pos(x, y);
}
for (int i = 0; i < N; i++) {
if (check[i]) {
continue;
}
vector<Pos> poss;
poss.push_back(all_pos[i]);
foo(i, poss);
for (int j = 0; j < poss.size(); j++) {
for (int k = j; k < poss.size(); k++) {
ans = max(ans, poss[j].distance(poss[k]));
}
}
}
printf("%10f\n", sqrt(ans) + 2);
return 0;
}