結果
問題 | No.202 1円玉投げ |
ユーザー |
![]() |
提出日時 | 2016-03-27 15:30:27 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 69 ms / 5,000 ms |
コード長 | 1,564 bytes |
コンパイル時間 | 841 ms |
コンパイル使用メモリ | 87,204 KB |
実行使用メモリ | 6,144 KB |
最終ジャッジ日時 | 2024-12-22 10:08:48 |
合計ジャッジ時間 | 3,193 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 38 |
ソースコード
/* -*- coding: utf-8 -*- * * 202.cc: No.202 1円玉投げ - yukicoder */ #include<cstdio> #include<cstdlib> #include<cstring> #include<cmath> #include<iostream> #include<string> #include<vector> #include<map> #include<set> #include<stack> #include<list> #include<queue> #include<deque> #include<algorithm> #include<numeric> #include<utility> #include<complex> #include<functional> using namespace std; /* constant */ const int MAX_N = 100000; const int MAX_X = 20000; const int MAX_Y = 20000; const int DX = 100; const int DY = 100; const int MAX_GX = MAX_X / DX; const int MAX_GY = MAX_Y / DY; const int RR = 20 * 20; /* typedef */ struct Pt { int x, y; Pt() {} Pt(int _x, int _y): x(_x), y(_y) {} int d2(const Pt &p) const { int dx = x - p.x, dy = y - p.y; return dx * dx + dy * dy; } }; typedef vector<Pt> vpt; /* global variables */ Pt pts[MAX_N]; vpt gps[MAX_GY + 1][MAX_GX + 1]; /* subroutines */ /* main */ int main() { int n; cin >> n; int pn = 0; for (int i = 0; i < n; i++) { Pt p; cin >> p.x >> p.y; int gpx = p.x / DX, gpy = p.y / DY; bool ok = true; for (int gy = gpy - 1; ok && gy <= gpy + 1; gy++) { if (gy < 0 || gy > MAX_GY) continue; for (int gx = gpx - 1; ok && gx <= gpx + 1; gx++) { if (gx < 0 || gx > MAX_GX) continue; vpt &gv = gps[gy][gx]; for (vpt::iterator vit = gv.begin(); vit != gv.end(); vit++) if (p.d2(*vit) < RR) ok = false; } } if (ok) { pn++; gps[gpy][gpx].push_back(p); } } printf("%d\n", pn); return 0; }