結果
| 問題 | No.94 圏外です。(EASY) |
| コンテスト | |
| ユーザー |
norioc
|
| 提出日時 | 2014-12-07 21:54:59 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,738 bytes |
| 記録 | |
| コンパイル時間 | 859 ms |
| コンパイル使用メモリ | 75,112 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-06-11 17:38:08 |
| 合計ジャッジ時間 | 1,941 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 7 WA * 15 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:68:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
68 | scanf("%d", &n);
| ~~~~~^~~~~~~~~~
main.cpp:73:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
73 | 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];
double d = sqrt(sq(p.x - q.x) + sq(p.y - q.y));
if (d <= 10) {
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++) {
double 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++) {
double len = sqrt(sq(g[j].x - g[k].x) + sq(g[j].y - g[k].y));
d = std::max(d, len);
}
}
d += 2;
ans = std::max(ans, d);
}
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