結果

問題 No.1265 Balloon Survival
ユーザー mkawa2mkawa2
提出日時 2020-11-08 17:25:17
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,193 ms / 2,000 ms
コード長 1,083 bytes
コンパイル時間 195 ms
コンパイル使用メモリ 11,020 KB
実行使用メモリ 79,216 KB
最終ジャッジ日時 2023-09-29 21:27:13
合計ジャッジ時間 15,161 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 19 ms
8,624 KB
testcase_01 AC 19 ms
8,652 KB
testcase_02 AC 19 ms
8,716 KB
testcase_03 AC 19 ms
8,636 KB
testcase_04 AC 19 ms
8,716 KB
testcase_05 AC 19 ms
8,828 KB
testcase_06 AC 19 ms
8,788 KB
testcase_07 AC 19 ms
8,780 KB
testcase_08 AC 18 ms
8,748 KB
testcase_09 AC 19 ms
8,632 KB
testcase_10 AC 20 ms
8,656 KB
testcase_11 AC 19 ms
8,752 KB
testcase_12 AC 20 ms
8,640 KB
testcase_13 AC 19 ms
8,716 KB
testcase_14 AC 113 ms
16,356 KB
testcase_15 AC 85 ms
14,216 KB
testcase_16 AC 42 ms
10,720 KB
testcase_17 AC 564 ms
44,436 KB
testcase_18 AC 55 ms
11,692 KB
testcase_19 AC 44 ms
10,944 KB
testcase_20 AC 102 ms
16,032 KB
testcase_21 AC 252 ms
25,728 KB
testcase_22 AC 139 ms
18,928 KB
testcase_23 AC 157 ms
19,856 KB
testcase_24 AC 1,193 ms
79,116 KB
testcase_25 AC 1,185 ms
78,700 KB
testcase_26 AC 1,178 ms
79,216 KB
testcase_27 AC 1,085 ms
78,380 KB
testcase_28 AC 1,101 ms
78,708 KB
testcase_29 AC 1,188 ms
79,124 KB
testcase_30 AC 1,146 ms
79,216 KB
testcase_31 AC 1,179 ms
78,616 KB
testcase_32 AC 1,106 ms
79,112 KB
testcase_33 AC 1,099 ms
79,176 KB
testcase_34 AC 19 ms
8,796 KB
testcase_35 AC 18 ms
8,576 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from operator import itemgetter
from itertools import *
from bisect import *
from collections import *
from heapq import *
import sys

# input=sys.stdin.buffer.readline
input=sys.stdin.readline

sys.setrecursionlimit(10**6)
int1 = lambda x: int(x)-1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(input())
def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())
def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return input()[:-1]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
dij = [(1, 0), (0, 1), (-1, 0), (0, -1)]

n=II()
xy=LLI(n)
dij=[]
for i,(x0,y0) in enumerate(xy):
    for j,(x1,y1) in enumerate(xy[:i]):
        dij.append(((x0-x1)**2+(y0-y1)**2,i,j))
dij.sort()
fin=[False]*n
ans=0
for d,i,j in dij:
    if fin[i] or fin[j]:continue
    if i==0 or j==0:
        fin[i+j]=True
        ans+=1
        n-=1
    else:
        fin[i]=fin[j]=True
        n-=2
    if n==1:break

print(ans)
0