結果

問題 No.1265 Balloon Survival
ユーザー masa_aa
提出日時 2020-10-23 22:22:51
言語 PyPy3
(8.0.1 + ACL)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 967 ms / 2,000 ms
+ 64µs
コード長 661 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 84 ms
コンパイル使用メモリ 64,464 KB
実行使用メモリ 147,812 KB
最終ジャッジ日時 2026-11-13 10:39:30
合計ジャッジ時間 15,626 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 35
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import sys
input = sys.stdin.readline
# def input(): return sys.stdin.readline().rstrip() # 文字列


def dist(x, y):
    one = x[0] - y[0]
    two = x[1] - y[1]
    return one * one + two * two


n = int(input())
p = [tuple(map(int, input().split())) for i in range(n)]
d = []
for i in range(n - 1):
    for j in range(i + 1, n):
        d.append((dist(p[i], p[j]), i, j))

d.sort(key=lambda x: x[0])
s = set(range(n))
ans = 0
i = 0
while len(s) > 1:
    _, x, y = d[i]
    if x == 0 or y == 0:
        if x + y in s:
            s.remove(x + y)
            ans += 1

    elif x in s and y in s:
        s.remove(x)
        s.remove(y)
    i += 1
print(ans)
0