結果
| 問題 |
No.202 1円玉投げ
|
| コンテスト | |
| ユーザー |
lam6er
|
| 提出日時 | 2025-03-20 20:20:35 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 209 ms / 5,000 ms |
| コード長 | 1,201 bytes |
| コンパイル時間 | 144 ms |
| コンパイル使用メモリ | 82,660 KB |
| 実行使用メモリ | 101,672 KB |
| 最終ジャッジ日時 | 2025-03-20 20:21:30 |
| 合計ジャッジ時間 | 6,328 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 38 |
ソースコード
import sys
from collections import defaultdict
def main():
n = int(sys.stdin.readline())
grid_map = defaultdict(list)
count = 0
for _ in range(n):
x, y = map(int, sys.stdin.readline().split())
cell_x = x // 20
cell_y = y // 20
valid = True
# Check adjacent cells (including current)
for dx in (-1, 0, 1):
for dy in (-1, 0, 1):
adj_cell_x = cell_x + dx
adj_cell_y = cell_y + dy
# Check each coin in the adjacent cell
for (ox, oy) in grid_map.get((adj_cell_x, adj_cell_y), []):
dx_p = x - ox
dy_p = y - oy
dist_sq = dx_p * dx_p + dy_p * dy_p
if dist_sq < 400:
valid = False
break # Break out of the current for-loop over coins
if not valid:
break # Break out of dy loop
if not valid:
break # Break out of dx loop
if valid:
grid_map[(cell_x, cell_y)].append((x, y))
count += 1
print(count)
if __name__ == '__main__':
main()
lam6er