結果

問題 No.1265 Balloon Survival
コンテスト
ユーザー c-yan
提出日時 2020-10-23 22:29:37
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 525 bytes
コンパイル時間 336 ms
コンパイル使用メモリ 82,832 KB
実行使用メモリ 154,408 KB
最終ジャッジ日時 2024-07-21 11:17:53
合計ジャッジ時間 9,530 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 20 TLE * 1 -- * 11
権限があれば一括ダウンロードができます

ソースコード

diff #

from heapq import heapify, heappop

N = int(input())
xy = [tuple(map(int, input().split())) for _ in range(N)]

a = []
for i in range(N - 1):
    for j in range(i + 1, N):
        d = (xy[i][0] - xy[j][0]) * (xy[i][0] - xy[j][0]) + (xy[i][1] - xy[j][1]) * (xy[i][1] - xy[j][1])
        a.append((d, i, j))
heapify(a)

result = 0
t = set()
while a:
    _, i, j = heappop(a)
    if i in t or j in t:
        continue
    if i == 0:
        result += 1
        t.add(j)
    else:
        t.add(i)
        t.add(j)
print(result)
0