結果
問題 | No.1265 Balloon Survival |
ユーザー |
![]() |
提出日時 | 2020-10-23 23:06:54 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 1,077 ms / 2,000 ms |
コード長 | 567 bytes |
コンパイル時間 | 247 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 93,984 KB |
最終ジャッジ日時 | 2024-07-21 12:25:45 |
合計ジャッジ時間 | 14,059 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 32 |
ソースコード
from operator import itemgetter N = int(input()) XY = [list(map(int, input().split())) for _ in range(N)] A = [((ax-bx)**2+(ay-by)**2, a, b) for a, (ax, ay) in enumerate(XY) for b, (bx, by) in enumerate(XY[a+1:], a+1)] A.sort(key=itemgetter(0)) ans = 0 Closed = [False] * N for _, a, b in A: if Closed[a] == Closed[b] == False: if a != 0 and b != 0: Closed[a] = True Closed[b] = True elif a == 0: Closed[b] = True ans += 1 else: Closed[a] = True ans += 1 print(ans)