結果

問題 No.19 ステージの選択
ユーザー ゆるくゆるく
提出日時 2014-11-13 03:05:10
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 1,032 bytes
コンパイル時間 893 ms
コンパイル使用メモリ 10,956 KB
実行使用メモリ 10,144 KB
最終ジャッジ日時 2023-08-30 03:21:32
合計ジャッジ時間 11,426 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
10,004 KB
testcase_01 AC 30 ms
9,952 KB
testcase_02 AC 30 ms
10,004 KB
testcase_03 AC 32 ms
10,032 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 451 ms
10,000 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
#sys.setrecursionlimit(n)
import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy

n = int(input())
e = [[int(i) for i in input().split()] for i in range(n)]

mn = 0xFFFFFFFF
def prim(i):
  heap = []
  use = deque([False for _ in range(n)])
  heapq.heappush(heap, ((e[i][0] << 8) + i))
  ret = 0
  global mn
  while(heap):
    v = heapq.heappop(heap)
    c = (v >> 8) / 10
    p = v & 0xFF
    if ret >= mn:
      return 0xFFFFFFFF
    if not(use.count(False)):
      return ret
    if use[p]:
      continue
    nc = 0
    if use[e[p][1] - 1]:
      nc = e[p][0] / 2
    else:
      nc = e[p][0]
    use[p] = True
    ret += nc
    for j in range(n):
      nc = 0
      if use[e[j][1] - 1]:
        nc = e[j][0] / 2
      else:
        nc = e[j][0]
      heapq.heappush(heap, (int(nc * 10) << 8) + j)
  return 0xFFFFFFFF

for i in range(n):
  mn = min(mn, prim(i))
print(mn)

0