結果

問題 No.1265 Balloon Survival
ユーザー proriboneproribone
提出日時 2020-10-24 00:22:49
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,551 ms / 2,000 ms
コード長 686 bytes
コンパイル時間 206 ms
コンパイル使用メモリ 82,244 KB
実行使用メモリ 119,424 KB
最終ジャッジ日時 2024-07-21 14:12:54
合計ジャッジ時間 19,467 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 32
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input=sys.stdin.readline

def dist(p,q):
    a,b=p[0]-q[0],p[1]-q[1]
    return a**2+b**2

def off(a,b):
    return a*10**9+b
def get(x):
    return x%10**9,x//10**9

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

isv=[True]*N

for i in range(N):
    for j in range(i+1,N):
        G.append((dist(point[i],point[j]),off(i,j)))
G.sort()
res=0
for d,x in G:
    i,j=get(x)
    if i==0:
        if isv[j]:
            res+=1
            isv[j]=False
    if j==0:
        if isv[i]:
            res+=1
            isv[i]=False
    else:
        if not isv[i] or not isv[j]:
            continue
        isv[i]=False
        isv[j]=False
print(res)
0