結果
問題 |
No.19 ステージの選択
|
ユーザー |
![]() |
提出日時 | 2014-11-13 03:05:10 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,032 bytes |
コンパイル時間 | 309 ms |
コンパイル使用メモリ | 12,800 KB |
実行使用メモリ | 11,776 KB |
最終ジャッジ日時 | 2024-12-31 10:09:17 |
合計ジャッジ時間 | 12,349 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 5 WA * 19 |
ソースコード
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)