結果

問題 No.202 1円玉投げ
ユーザー maine_honzuki
提出日時 2020-12-22 00:49:03
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 88 ms / 5,000 ms
コード長 984 bytes
コンパイル時間 1,919 ms
コンパイル使用メモリ 197,656 KB
最終ジャッジ日時 2025-01-17 05:59:09
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 38
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

vector<pair<int, int>> mesh[510][510];

int main() {
    auto overlap = [](pair<int, int> P, pair<int, int> Q) {
        int dx = P.first - Q.first, dy = P.second - Q.second;
        return dx * dx + dy * dy < 400;
    };
    auto out = [&](pair<int, int> P) {
        int i = P.first / 40, j = P.second / 40;
        bool flag = false;
        for (int k = max(0, i - 1); k <= i + 1; k++) {
            for (int l = max(0, j - 1); l <= j + 1; l++) {
                for (auto& Q : mesh[k][l]) {
                    flag |= overlap(P, Q);
                }
            }
        }
        return flag;
    };

    int N, ans = 0;
    cin >> N;
    while (N--) {
        pair<int, int> P;
        cin >> P.first >> P.second;
        if (out(P))
            continue;
        else {
            int i = P.first / 40, j = P.second / 40;
            mesh[i][j].emplace_back(P);
            ans++;
        }
    }

    cout << ans << endl;
}
0