結果

問題 No.1265 Balloon Survival
コンテスト
ユーザー tktk_snsn
提出日時 2021-01-11 19:15:19
言語 Python3
(3.15.0 + numpy 2.5.4 + scipy 1.18.1 + ACL)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
AC  
実行時間 983 ms / 2,000 ms
+ 502µs
コード長 562 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 54 ms
コンパイル使用メモリ 15,104 KB
実行使用メモリ 89,268 KB
最終ジャッジ日時 2026-09-27 11:03:50
合計ジャッジ時間 13,808 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge4_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 32
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)

N = int(input())
XY = tuple(tuple(map(int, input().split())) for _ in range(N))
dist = []
for i, (x, y) in enumerate(XY):
    for j, (xx, yy) in enumerate(XY):
        if j >= i:
            break
        d = (x - xx) ** 2 + (y - yy) ** 2
        dist.append((d, j, i))


seen = [0] * N
ans = 0
dist.sort()
for _, i, j in dist:
    if seen[i] or seen[j]:
        continue
    if i == 0:
        seen[j] = 1
        ans += 1
    else:
        seen[i] = 1
        seen[j] = 1

print(ans)
0