結果

問題 No.202 1円玉投げ
ユーザー rpy3cpprpy3cpp
提出日時 2015-05-03 23:52:41
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 918 ms / 5,000 ms
コード長 1,027 bytes
コンパイル時間 640 ms
コンパイル使用メモリ 10,796 KB
実行使用メモリ 46,404 KB
最終ジャッジ日時 2023-08-23 21:41:07
合計ジャッジ時間 14,487 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 908 ms
32,868 KB
testcase_01 AC 548 ms
46,404 KB
testcase_02 AC 18 ms
8,528 KB
testcase_03 AC 18 ms
8,540 KB
testcase_04 AC 18 ms
8,696 KB
testcase_05 AC 41 ms
11,068 KB
testcase_06 AC 457 ms
38,800 KB
testcase_07 AC 518 ms
41,716 KB
testcase_08 AC 525 ms
41,732 KB
testcase_09 AC 259 ms
27,856 KB
testcase_10 AC 104 ms
17,108 KB
testcase_11 AC 210 ms
25,048 KB
testcase_12 AC 212 ms
25,576 KB
testcase_13 AC 117 ms
19,248 KB
testcase_14 AC 43 ms
11,404 KB
testcase_15 AC 253 ms
27,468 KB
testcase_16 AC 749 ms
34,460 KB
testcase_17 AC 758 ms
34,432 KB
testcase_18 AC 753 ms
34,376 KB
testcase_19 AC 232 ms
26,524 KB
testcase_20 AC 397 ms
35,300 KB
testcase_21 AC 225 ms
26,472 KB
testcase_22 AC 22 ms
8,788 KB
testcase_23 AC 23 ms
8,708 KB
testcase_24 AC 21 ms
8,624 KB
testcase_25 AC 20 ms
8,700 KB
testcase_26 AC 22 ms
8,824 KB
testcase_27 AC 22 ms
8,788 KB
testcase_28 AC 20 ms
8,764 KB
testcase_29 AC 22 ms
8,728 KB
testcase_30 AC 24 ms
8,892 KB
testcase_31 AC 20 ms
8,676 KB
testcase_32 AC 21 ms
8,892 KB
testcase_33 AC 25 ms
8,680 KB
testcase_34 AC 29 ms
8,788 KB
testcase_35 AC 864 ms
31,876 KB
testcase_36 AC 918 ms
32,928 KB
testcase_37 AC 586 ms
43,692 KB
testcase_38 AC 856 ms
32,300 KB
testcase_39 AC 19 ms
8,608 KB
testcase_40 AC 19 ms
8,572 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
import collections

def read_data():
    N = int(input())
    lines = sys.stdin.readlines()
    XY = []
    for xy in lines:
        x, y = map(int, xy.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