結果

問題 No.202 1円玉投げ
ユーザー mayoko_mayoko_
提出日時 2015-05-03 23:48:38
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 128 ms / 5,000 ms
コード長 1,402 bytes
コンパイル時間 1,339 ms
コンパイル使用メモリ 148,584 KB
実行使用メモリ 124,100 KB
最終ジャッジ日時 2023-08-23 21:39:26
合計ジャッジ時間 6,105 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 91 ms
123,916 KB
testcase_01 AC 128 ms
124,028 KB
testcase_02 AC 46 ms
120,120 KB
testcase_03 AC 47 ms
120,056 KB
testcase_04 AC 47 ms
120,056 KB
testcase_05 AC 52 ms
120,248 KB
testcase_06 AC 110 ms
123,016 KB
testcase_07 AC 118 ms
123,384 KB
testcase_08 AC 120 ms
123,436 KB
testcase_09 AC 87 ms
121,960 KB
testcase_10 AC 63 ms
120,840 KB
testcase_11 AC 80 ms
121,656 KB
testcase_12 AC 81 ms
121,700 KB
testcase_13 AC 65 ms
121,000 KB
testcase_14 AC 52 ms
120,372 KB
testcase_15 AC 85 ms
121,864 KB
testcase_16 AC 90 ms
123,912 KB
testcase_17 AC 80 ms
124,004 KB
testcase_18 AC 79 ms
123,932 KB
testcase_19 AC 82 ms
121,756 KB
testcase_20 AC 105 ms
122,732 KB
testcase_21 AC 82 ms
121,796 KB
testcase_22 AC 46 ms
120,136 KB
testcase_23 AC 47 ms
120,148 KB
testcase_24 AC 47 ms
120,072 KB
testcase_25 AC 46 ms
120,076 KB
testcase_26 AC 45 ms
120,092 KB
testcase_27 AC 47 ms
120,104 KB
testcase_28 AC 46 ms
120,276 KB
testcase_29 AC 47 ms
120,068 KB
testcase_30 AC 47 ms
120,180 KB
testcase_31 AC 46 ms
120,076 KB
testcase_32 AC 47 ms
120,100 KB
testcase_33 AC 46 ms
120,124 KB
testcase_34 AC 47 ms
120,224 KB
testcase_35 AC 78 ms
124,100 KB
testcase_36 AC 80 ms
123,996 KB
testcase_37 AC 125 ms
123,680 KB
testcase_38 AC 80 ms
123,980 KB
testcase_39 AC 46 ms
120,068 KB
testcase_40 AC 46 ms
120,080 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

#define rep(i, n) for (int (i) = 0; (i) < (int)(n); (i)++)

const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;

const int MAXN = 122222;
ll X[MAXN], Y[MAXN];

vector<pii> pos[2222][2222];

ll square(int x) {return x*x;}

bool in(const pii& p, const pii& q) {
    return square(p.first-q.first) + square(p.second-q.second) < 20*20;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> X[i] >> Y[i];
    }
    int ans = 0;
    for (int i = 0; i < N; i++) {
        int y = Y[i]/10;
        int x = X[i]/10;
        bool ng = false;
        for (int dx = -3; dx <= 3; dx++) {
            for (int dy = -3; dy <= 3; dy++) {
                int nx = x+dx;
                int ny = y+dy;
                if (nx < 0 || ny < 0) continue;
                for (auto p : pos[ny][nx]) {
                    if (in(p, pii(Y[i], X[i]))) {
                        ng = true;
                        break;
                    }
                }
                if (ng) break;
            }
            if (ng) break;
        }
        if (!ng) {
            ans++;
            pos[y][x].push_back(pii(Y[i], X[i]));
        }
    }
    cout << ans << endl;
    return 0;
}
0