結果
問題 | No.202 1円玉投げ |
ユーザー |
![]() |
提出日時 | 2015-05-04 18:33:10 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 86 ms / 5,000 ms |
コード長 | 1,397 bytes |
コンパイル時間 | 770 ms |
コンパイル使用メモリ | 74,176 KB |
実行使用メモリ | 100,224 KB |
最終ジャッジ日時 | 2024-12-22 08:22:20 |
合計ジャッジ時間 | 4,356 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 38 |
ソースコード
#include <iostream> #include <string> #include <vector> #include <functional> #include <algorithm> #include <cmath> #include <array> #define REP(i, n) for(int i=0;i<(n);i++) using namespace std; typedef pair<int, int> P; const int MAX_N = 100000; array<array<vector<P>, 2000>, 20000 / 10> fields; bool is_on(pair<int, int> &a, pair<int, int> &b) { double dist = (a.first - b.first) * (a.first - b.first) + (a.second - b.second) * (a.second - b.second); dist = sqrt(dist); return dist < 20; } int main() { cin.tie(0); ios::sync_with_stdio(false); int N; cin >> N; int x, y; cin >> x >> y; N--; fields[x / 20][y / 20].emplace_back(x, y); int ans = 1; REP(k, N) { cin >> x >> y; P current(x, y); int fx = x / 20, fy = y / 20; bool flg = true; for (int i = -1; i <= 1 && flg; ++i) { for (int j = -1; j <= 1 && flg; ++j) { if (fx + i < 0 || fx + i >= 2000 || fy + j < 0 || fy + j >= 2000) continue; for (auto p: fields[fx + i][fy + j]) { if (is_on(p, current)) { flg = false; break; } } } } if (flg) { fields[fx][fy].push_back(current); ans++; } } cout << ans << endl; return 0; }