結果

問題 No.202 1円玉投げ
ユーザー n_knuu
提出日時 2015-05-05 00:34:49
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 501 ms / 5,000 ms
コード長 803 bytes
コンパイル時間 445 ms
コンパイル使用メモリ 82,364 KB
実行使用メモリ 117,840 KB
最終ジャッジ日時 2024-12-22 08:30:43
合計ジャッジ時間 11,574 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 38
権限があれば一括ダウンロードができます

ソースコード

diff #

from math import hypot
N = int(input())

def isOverlap(x1, y1, x2, y2, r=10):
    return hypot(x1-x2, y1-y2) < r * 2

def check(x, y):
    near = [(-1, -1), (0, -1), (1, -1),
            (-1, 0), (0, 0), (1, 0),
            (-1, 1), (0, 1), (1, 1)]
    for dx, dy in near:
        nx = x//20 + dx
        ny = y//20 + dy
        if 0 <= nx <= 1000 and 0 <= ny <= 1000:
            for cx, cy in field[nx][ny]:
#                print(x, y, nx, ny, cx, cy, isOverlap(x, y, cx, cy))
                if isOverlap(x, y, cx, cy):
                    return False
    return True
            

field = [[[] for _ in range(1001)] for _ in range(1001)]
ans = 0
for _ in range(N):
    x, y = map(int, input().split())
    if check(x, y):
        ans += 1
        field[x//20][y//20].append((x, y))    
print(ans)
0