結果

問題 No.1265 Balloon Survival
ユーザー stnkienstnkien
提出日時 2020-10-23 22:31:21
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,160 ms / 2,000 ms
コード長 793 bytes
コンパイル時間 642 ms
コンパイル使用メモリ 10,876 KB
実行使用メモリ 133,760 KB
最終ジャッジ日時 2023-09-28 16:38:34
合計ジャッジ時間 14,897 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
7,864 KB
testcase_01 AC 16 ms
7,872 KB
testcase_02 AC 17 ms
7,892 KB
testcase_03 AC 17 ms
7,872 KB
testcase_04 AC 17 ms
7,804 KB
testcase_05 AC 17 ms
7,948 KB
testcase_06 AC 18 ms
7,920 KB
testcase_07 AC 17 ms
7,808 KB
testcase_08 AC 17 ms
7,964 KB
testcase_09 AC 17 ms
7,984 KB
testcase_10 AC 17 ms
7,792 KB
testcase_11 AC 17 ms
7,868 KB
testcase_12 AC 18 ms
8,260 KB
testcase_13 AC 17 ms
7,860 KB
testcase_14 AC 139 ms
21,752 KB
testcase_15 AC 107 ms
17,600 KB
testcase_16 AC 47 ms
11,736 KB
testcase_17 AC 584 ms
73,004 KB
testcase_18 AC 63 ms
13,308 KB
testcase_19 AC 51 ms
12,212 KB
testcase_20 AC 136 ms
21,400 KB
testcase_21 AC 291 ms
38,840 KB
testcase_22 AC 183 ms
26,420 KB
testcase_23 AC 199 ms
28,296 KB
testcase_24 AC 1,133 ms
133,740 KB
testcase_25 AC 1,146 ms
133,700 KB
testcase_26 AC 1,135 ms
133,688 KB
testcase_27 AC 1,160 ms
133,760 KB
testcase_28 AC 1,140 ms
133,628 KB
testcase_29 AC 1,134 ms
133,760 KB
testcase_30 AC 1,116 ms
133,648 KB
testcase_31 AC 1,125 ms
133,740 KB
testcase_32 AC 1,117 ms
133,676 KB
testcase_33 AC 1,116 ms
133,644 KB
testcase_34 AC 17 ms
8,256 KB
testcase_35 AC 17 ms
7,868 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10**7)
N = int(input())
X = [tuple(map(int, line.split())) for line in sys.stdin.buffer.readlines()]

INF = 1<<60
D = [[INF]*N for _ in [0]*N]

for i in range(N):
    x, y = X[i]
    for j in range(i+1, N):
        u, v = X[j]
        D[i][j] = D[j][i] = (x-u)**2 + (y-v)**2

D = [sorted((d, j) for j, d in enumerate(Di))[:-1] for Di in D]

status = [0]*N
status[0] = 1

def dfs(i=0):
    cnt = 0
    for d, j in D[i]:
        if status[j] == 2:
            continue
        elif status[j] == 1:
            if j == 0: cnt += 1
            else: status[j] = 2
            status[i] = 2
            return cnt
        status[j] = 1
        cnt += dfs(j)
        if status[i] == 2:
            break
    return cnt

print(dfs())
0