結果
問題 |
No.94 圏外です。(EASY)
|
ユーザー |
|
提出日時 | 2016-12-18 16:10:16 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,041 bytes |
コンパイル時間 | 774 ms |
コンパイル使用メモリ | 60,252 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-14 08:25:56 |
合計ジャッジ時間 | 1,467 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 3 WA * 19 |
ソースコード
#include <iostream> #include <cmath> using namespace std; bool check[1000]; int Xs[1000], Ys[1000]; int N; class Pos { public: int x; int y; 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); } }; void foo(int index, Pos now, Pos &pos1, Pos &pos2, Pos &pos3, Pos &pos4) { for (int i = 0; i < N; i++) { if (check[i]) { continue; } int x = Xs[i]; int y = Ys[i]; int distance = (x - now.x) * (x - now.x) + (y - now.y) * (y - now.y); if (distance <= 100) { check[i] = true; if(pos1.x > x && pos1.y > y) { pos1.x = x; pos1.y = y; } if(pos2.x > x && pos2.y < y) { pos2.x = x; pos2.y = y; } if(pos3.x < x && pos3.y > y) { pos3.x = x; pos3.y = y; } if(pos4.x < x && pos4.y < y) { pos4.x = x; pos4.y = y; } foo(i, Pos(x, y), pos1, pos2, pos3, pos4); } } } int main() { cin >> N; for (int i = 0; i < N; i++) { check[i] = false; } int ans = 0; for (int i = 0; i < N; i++) { cin >> Xs[i] >> Ys[i]; } for (int i = 0; i < N; i++) { if (check[i]) { continue; } Pos pos1 = Pos(Xs[i], Ys[i]); Pos pos2 = Pos(Xs[i], Ys[i]); Pos pos3 = Pos(Xs[i], Ys[i]); Pos pos4 = Pos(Xs[i], Ys[i]); foo(i, Pos(Xs[i], Ys[i]), pos1, pos2, pos3, pos4); int a[] = {ans, pos1.distance(pos2), pos1.distance(pos3), pos1.distance(pos4), pos2.distance(pos3), pos2.distance(pos4), pos3.distance(pos4)}; int tmp = 0; for (auto b : a) { if (b > tmp) { tmp = b; } } ans = tmp; } cout << sqrt(ans) + 2 << endl; return 0; }