結果

問題 No.202 1円玉投げ
ユーザー rpy3cpprpy3cpp
提出日時 2015-05-04 00:05:07
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,072 ms / 5,000 ms
コード長 990 bytes
コンパイル時間 87 ms
コンパイル使用メモリ 10,924 KB
実行使用メモリ 45,428 KB
最終ジャッジ日時 2023-08-23 21:46:55
合計ジャッジ時間 16,416 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,072 ms
32,444 KB
testcase_01 AC 719 ms
45,428 KB
testcase_02 AC 18 ms
8,616 KB
testcase_03 AC 19 ms
8,584 KB
testcase_04 AC 18 ms
8,520 KB
testcase_05 AC 50 ms
11,020 KB
testcase_06 AC 626 ms
37,892 KB
testcase_07 AC 713 ms
40,664 KB
testcase_08 AC 704 ms
40,812 KB
testcase_09 AC 351 ms
27,488 KB
testcase_10 AC 140 ms
16,900 KB
testcase_11 AC 276 ms
24,804 KB
testcase_12 AC 286 ms
25,084 KB
testcase_13 AC 156 ms
19,000 KB
testcase_14 AC 55 ms
11,448 KB
testcase_15 AC 341 ms
26,952 KB
testcase_16 AC 897 ms
33,592 KB
testcase_17 AC 894 ms
33,716 KB
testcase_18 AC 899 ms
33,696 KB
testcase_19 AC 311 ms
26,168 KB
testcase_20 AC 528 ms
35,340 KB
testcase_21 AC 310 ms
25,920 KB
testcase_22 AC 25 ms
8,816 KB
testcase_23 AC 24 ms
8,864 KB
testcase_24 AC 22 ms
8,700 KB
testcase_25 AC 22 ms
8,716 KB
testcase_26 AC 25 ms
8,760 KB
testcase_27 AC 24 ms
8,832 KB
testcase_28 AC 23 ms
8,668 KB
testcase_29 AC 22 ms
8,792 KB
testcase_30 AC 25 ms
8,960 KB
testcase_31 AC 22 ms
8,784 KB
testcase_32 AC 24 ms
9,100 KB
testcase_33 AC 26 ms
8,724 KB
testcase_34 AC 30 ms
8,688 KB
testcase_35 AC 1,011 ms
31,616 KB
testcase_36 AC 1,057 ms
32,408 KB
testcase_37 AC 761 ms
42,772 KB
testcase_38 AC 999 ms
31,940 KB
testcase_39 AC 20 ms
8,644 KB
testcase_40 AC 20 ms
8,724 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import collections

def read_data():
    N = int(input())
    XY = []
    for i in range(N):
        x, y = map(int, input().split())
        XY.append((x, y))
    return N, XY

def solve(N, XY, r = 10, size = 50):
    cells = collections.defaultdict(list)
    count = 0
    threshold = 4 * r * r
    for x, y in XY:
        if not overlap(x, y, cells, size, threshold):
            count += 1
            register_cell(x, y, cells, size)
    return count

def overlap(x, y, cells, size, threshold):
    xc = x // size
    yc = y // size
    for xr in [xc-1, xc, xc+1]:
        for yr in [yc-1, yc, yc+1]:
            if (xr, yr) in cells:
                for xx, yy in cells[xr, yr]:
                    if (x - xx) ** 2 + (y - yy) ** 2 < threshold:
                        return True
    return False

def register_cell(x, y, cells, size):
    xc = x // size
    yc = y // size
    cells[xc, yc].append((x, y))

if __name__ == "__main__":
    N, XY = read_data()
    print(solve(N, XY))
0