結果

問題 No.202 1円玉投げ
ユーザー agatanagatan
提出日時 2015-05-04 18:33:10
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 87 ms / 5,000 ms
コード長 1,397 bytes
コンパイル時間 625 ms
コンパイル使用メモリ 74,724 KB
実行使用メモリ 100,400 KB
最終ジャッジ日時 2023-08-23 22:18:02
合計ジャッジ時間 4,763 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
100,284 KB
testcase_01 AC 82 ms
100,272 KB
testcase_02 AC 39 ms
97,296 KB
testcase_03 AC 39 ms
97,096 KB
testcase_04 AC 39 ms
97,276 KB
testcase_05 AC 40 ms
97,528 KB
testcase_06 AC 79 ms
99,504 KB
testcase_07 AC 84 ms
99,628 KB
testcase_08 AC 85 ms
99,640 KB
testcase_09 AC 63 ms
98,616 KB
testcase_10 AC 50 ms
97,772 KB
testcase_11 AC 59 ms
98,372 KB
testcase_12 AC 59 ms
98,436 KB
testcase_13 AC 51 ms
97,844 KB
testcase_14 AC 42 ms
97,464 KB
testcase_15 AC 64 ms
98,688 KB
testcase_16 AC 65 ms
100,240 KB
testcase_17 AC 68 ms
100,400 KB
testcase_18 AC 68 ms
100,340 KB
testcase_19 AC 62 ms
98,532 KB
testcase_20 AC 75 ms
99,248 KB
testcase_21 AC 63 ms
98,460 KB
testcase_22 AC 40 ms
97,420 KB
testcase_23 AC 40 ms
97,144 KB
testcase_24 AC 38 ms
97,272 KB
testcase_25 AC 41 ms
97,280 KB
testcase_26 AC 40 ms
97,164 KB
testcase_27 AC 40 ms
97,204 KB
testcase_28 AC 38 ms
97,308 KB
testcase_29 AC 40 ms
97,164 KB
testcase_30 AC 40 ms
97,412 KB
testcase_31 AC 41 ms
97,208 KB
testcase_32 AC 38 ms
97,336 KB
testcase_33 AC 42 ms
97,372 KB
testcase_34 AC 41 ms
97,204 KB
testcase_35 AC 69 ms
100,236 KB
testcase_36 AC 75 ms
100,328 KB
testcase_37 AC 87 ms
99,928 KB
testcase_38 AC 72 ms
100,240 KB
testcase_39 AC 40 ms
97,120 KB
testcase_40 AC 40 ms
97,280 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0