結果

問題 No.1265 Balloon Survival
ユーザー persimmon-persimmonpersimmon-persimmon
提出日時 2021-02-20 10:22:03
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 766 bytes
コンパイル時間 2,063 ms
コンパイル使用メモリ 81,636 KB
実行使用メモリ 196,180 KB
最終ジャッジ日時 2023-10-17 14:29:16
合計ジャッジ時間 19,602 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
53,408 KB
testcase_01 AC 38 ms
53,408 KB
testcase_02 RE -
testcase_03 AC 38 ms
53,412 KB
testcase_04 AC 38 ms
53,412 KB
testcase_05 AC 38 ms
53,412 KB
testcase_06 AC 38 ms
53,412 KB
testcase_07 AC 38 ms
53,412 KB
testcase_08 AC 38 ms
53,412 KB
testcase_09 AC 38 ms
53,412 KB
testcase_10 AC 38 ms
53,412 KB
testcase_11 AC 39 ms
53,412 KB
testcase_12 AC 38 ms
53,412 KB
testcase_13 AC 38 ms
53,412 KB
testcase_14 AC 222 ms
88,632 KB
testcase_15 AC 180 ms
84,552 KB
testcase_16 AC 98 ms
78,764 KB
testcase_17 AC 751 ms
132,860 KB
testcase_18 AC 126 ms
80,532 KB
testcase_19 AC 101 ms
79,196 KB
testcase_20 AC 205 ms
87,820 KB
testcase_21 AC 398 ms
101,988 KB
testcase_22 AC 268 ms
92,332 KB
testcase_23 AC 294 ms
93,888 KB
testcase_24 AC 1,434 ms
196,180 KB
testcase_25 AC 1,404 ms
196,124 KB
testcase_26 AC 1,415 ms
196,112 KB
testcase_27 AC 1,386 ms
195,520 KB
testcase_28 AC 1,392 ms
195,764 KB
testcase_29 AC 1,386 ms
195,696 KB
testcase_30 AC 1,400 ms
195,468 KB
testcase_31 AC 1,395 ms
195,424 KB
testcase_32 AC 1,388 ms
195,496 KB
testcase_33 AC 1,391 ms
195,504 KB
testcase_34 AC 45 ms
59,248 KB
testcase_35 AC 37 ms
53,452 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n=int(input())
xy=[list(map(int,input().split())) for _ in range(n)]
mat=[[] for i in range(n)]
for i in range(n):
  xi,yi=xy[i]
  for j in range(i):
    xj,yj=xy[j]
    d=(xi-xj)**2+(yi-yj)**2
    mat[i].append([d,i,j])
    mat[j].append([d,j,i])

from heapq import heappop,heappush
todo=[]
for i in range(n):
  mat[i].sort(reverse=True)
  heappush(todo,mat[i].pop())

ans=0
seen=[0]*n
while todo:
  d,i,j=heappop(todo)
  if seen[i]==1 or seen[j]==1:
    if seen[i]==0 and mat[i]:
      heappush(todo,mat[i].pop())
    if seen[j]==0 and mat[j]:
      heappush(todo,mat[j].pop())
  elif i==0 or j==0:
    ans+=1
    seen[i]=1
    seen[j]=1
    seen[0]=0
    if seen[i]==0 and mat[i]:
      heappush(todo,mat[i].pop())
  else:
    seen[i]=1
    seen[j]=1
print(ans)

0