結果

問題 No.1265 Balloon Survival
ユーザー uni_pythonuni_python
提出日時 2020-11-01 22:54:42
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,494 ms / 2,000 ms
コード長 918 bytes
コンパイル時間 275 ms
コンパイル使用メモリ 87,232 KB
実行使用メモリ 130,748 KB
最終ジャッジ日時 2023-09-29 11:30:43
合計ジャッジ時間 14,866 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 69 ms
71,472 KB
testcase_01 AC 70 ms
71,352 KB
testcase_02 AC 72 ms
71,444 KB
testcase_03 AC 71 ms
71,504 KB
testcase_04 AC 74 ms
71,604 KB
testcase_05 AC 73 ms
71,292 KB
testcase_06 AC 73 ms
71,340 KB
testcase_07 AC 72 ms
71,216 KB
testcase_08 AC 72 ms
71,596 KB
testcase_09 AC 73 ms
71,392 KB
testcase_10 AC 72 ms
71,496 KB
testcase_11 AC 71 ms
71,460 KB
testcase_12 AC 72 ms
71,620 KB
testcase_13 AC 69 ms
71,192 KB
testcase_14 AC 195 ms
82,332 KB
testcase_15 AC 164 ms
81,908 KB
testcase_16 AC 99 ms
76,420 KB
testcase_17 AC 693 ms
105,392 KB
testcase_18 AC 121 ms
80,124 KB
testcase_19 AC 101 ms
76,788 KB
testcase_20 AC 178 ms
82,244 KB
testcase_21 AC 356 ms
90,696 KB
testcase_22 AC 219 ms
82,712 KB
testcase_23 AC 252 ms
86,448 KB
testcase_24 AC 1,456 ms
129,004 KB
testcase_25 AC 1,494 ms
130,256 KB
testcase_26 AC 1,476 ms
130,748 KB
testcase_27 AC 1,376 ms
129,852 KB
testcase_28 AC 1,362 ms
130,384 KB
testcase_29 AC 1,413 ms
130,540 KB
testcase_30 AC 1,375 ms
130,364 KB
testcase_31 AC 1,458 ms
130,024 KB
testcase_32 AC 1,364 ms
130,244 KB
testcase_33 AC 1,377 ms
129,564 KB
testcase_34 AC 72 ms
71,628 KB
testcase_35 AC 72 ms
71,436 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input=sys.stdin.readline
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))



N=I()

if N==1:
    print(0)
    exit()
if N==2:
    print(1)
    exit()

X=[0]*N
Y=[0]*N
for i in range(N):
    X[i],Y[i]=MI()

M=10**3+1
M2=M*M

def enc(d,i,j):
    temp=d*M2 + i*M + j
    return temp

def dec(temp):
    d,ij=divmod(temp,M2)
    i,j=divmod(ij,M)
    return d,i,j




# 取り除いた or 消えた
used=[0]*N

L=[0]*(N*(N-1)//2)
k=0

for i in range(N):
    for j in range(i+1,N):
        d=(X[i]-X[j])**2 + (Y[i]-Y[j])**2
        L[k]=enc(d,i,j)
        k+=1

ans=0
L.sort()
S=0

for aaa in L:
    _,i,j=dec(aaa)
    if i==0:
        if used[j]==0:
            ans+=1
            used[j]=1
            S+=1
    if used[i]==0 and used[j]==0:
        used[i]=1
        used[j]=1
        S+=2
    if S==N-1:
        break
        
print(ans)
0