結果
| 問題 | No.94 圏外です。(EASY) |
| コンテスト | |
| ユーザー |
norioc
|
| 提出日時 | 2014-12-07 22:37:16 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,709 bytes |
| 記録 | |
| コンパイル時間 | 663 ms |
| コンパイル使用メモリ | 74,900 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-06-11 17:45:05 |
| 合計ジャッジ時間 | 1,382 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 7 WA * 15 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:66:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
66 | scanf("%d", &n);
| ~~~~~^~~~~~~~~~
main.cpp:71:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
71 | scanf("%d %d", &x, &y);
| ~~~~~^~~~~~~~~~~~~~~~~
ソースコード
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <vector>
using namespace std;
#define For(i,x) for (int i=0; i<(int)(x); i++)
template <class T>
T sq(T n) {
return n*n;
}
struct Pt {
int x, y;
Pt(int x, int y) : x(x), y(y) {}
};
double calc(vector<Pt> & v) {
vector< vector<Pt> > groups;
for (int i = 0; i < v.size(); i++) {
bool joined = false;
const Pt& p = v[i];
for (int j = 0; j < groups.size(); j++) {
for (int k = 0; k < groups[j].size(); k++) {
const Pt& q = groups[j][k];
int d = sq(p.x - q.x) + sq(p.y - q.y);
if (d <= 100) {
groups[j].push_back(p);
joined = true;
break;
}
}
if (joined) break;
}
if (!joined) {
vector<Pt> newgroup;
newgroup.push_back(p);
groups.push_back(newgroup);
}
}
double ans = 1;
for (int i = 0; i < groups.size(); i++) {
int d = 0;
const vector<Pt>& g = groups[i];
for (int j = 0; j < g.size(); j++) {
for (int k = j+1; k < g.size(); k++) {
int len = sq(g[j].x - g[k].x) + sq(g[j].y - g[k].y);
d = std::max(d, len);
}
}
ans = std::max(ans, sqrt(d) + 2);
}
return ans;
}
int main() {
int n;
scanf("%d", &n);
vector<Pt> v;
For(i, n) {
int x, y;
scanf("%d %d", &x, &y);
v.push_back(Pt(x, y));
}
printf("%lf\n", calc(v));
}
norioc