結果

問題 No.202 1円玉投げ
ユーザー pekempeypekempey
提出日時 2015-08-12 15:15:01
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 75 ms / 5,000 ms
コード長 1,234 bytes
コンパイル時間 2,196 ms
コンパイル使用メモリ 147,208 KB
実行使用メモリ 7,296 KB
最終ジャッジ日時 2023-08-23 23:09:40
合計ジャッジ時間 4,463 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
6,636 KB
testcase_01 AC 69 ms
7,296 KB
testcase_02 AC 3 ms
4,504 KB
testcase_03 AC 2 ms
4,500 KB
testcase_04 AC 3 ms
4,504 KB
testcase_05 AC 7 ms
4,724 KB
testcase_06 AC 60 ms
7,032 KB
testcase_07 AC 68 ms
7,088 KB
testcase_08 AC 67 ms
7,084 KB
testcase_09 AC 39 ms
6,384 KB
testcase_10 AC 17 ms
5,364 KB
testcase_11 AC 32 ms
5,912 KB
testcase_12 AC 33 ms
6,020 KB
testcase_13 AC 19 ms
5,440 KB
testcase_14 AC 7 ms
4,972 KB
testcase_15 AC 37 ms
6,180 KB
testcase_16 AC 64 ms
6,624 KB
testcase_17 AC 65 ms
6,616 KB
testcase_18 AC 64 ms
6,636 KB
testcase_19 AC 36 ms
6,248 KB
testcase_20 AC 55 ms
6,652 KB
testcase_21 AC 34 ms
6,012 KB
testcase_22 AC 3 ms
4,556 KB
testcase_23 AC 3 ms
4,560 KB
testcase_24 AC 3 ms
4,508 KB
testcase_25 AC 3 ms
4,484 KB
testcase_26 AC 3 ms
4,504 KB
testcase_27 AC 3 ms
4,468 KB
testcase_28 AC 3 ms
4,492 KB
testcase_29 AC 4 ms
4,504 KB
testcase_30 AC 3 ms
4,560 KB
testcase_31 AC 3 ms
4,448 KB
testcase_32 AC 3 ms
4,560 KB
testcase_33 AC 3 ms
4,488 KB
testcase_34 AC 3 ms
4,460 KB
testcase_35 AC 68 ms
6,568 KB
testcase_36 AC 72 ms
6,784 KB
testcase_37 AC 75 ms
7,224 KB
testcase_38 AC 71 ms
6,620 KB
testcase_39 AC 3 ms
4,432 KB
testcase_40 AC 2 ms
4,560 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i, a) for (int i = 0; i < (a); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); i++)
#define repr(i, a) for (int i = (a) - 1; i >= 0; i--)
#define repr2(i, a, b) for (int i = (b) - 1; i >= (a); i--)
using namespace std;
typedef long long ll;
const ll inf = 1e9;
const ll mod = 1e9 + 7;

const ll U = 100;
const int W = 22000 / U;
const int H = 22000 / U;
vector<int> bucket[W][H];
ll xs[100000], ys[100000];

ll sq(ll x) {
    return x * x;
}

bool intersect(int i, int j) {
    return sq(xs[j] - xs[i]) + sq(ys[j] - ys[i]) < sq(20);
}

void put(int k) {
    ll x = xs[k];
    ll y = ys[k];
    int bx = x / U;
    int by = y / U;

    bool b = false;

    rep2 (dx, -1, 2) rep2 (dy, -1, 2) {
        int nx = bx + dx;
        int ny = by + dy;

        for (int i : bucket[nx][ny]) {
            if (intersect(k, i)) {
                b = true;
            }
        }
    }

    if (!b) {
        bucket[bx][by].push_back(k);
    }
}

int main() {
    int N;
    cin >> N;
    rep (i, N) {
        cin >> xs[i] >> ys[i];
        xs[i] += U;
        ys[i] += U;
    }

    rep (i, N) put(i);

    int ans = 0;
    rep (i, W) rep (j, H) ans += bucket[i][j].size();
    cout << ans << endl;
}
0