結果

問題 No.1814 Uribo Road (Easy)
ユーザー ShirotsumeShirotsume
提出日時 2021-11-04 22:27:09
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,324 bytes
コンパイル時間 454 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 80,128 KB
最終ジャッジ日時 2024-05-01 17:29:52
合計ジャッジ時間 8,412 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 57 ms
61,824 KB
testcase_02 WA -
testcase_03 AC 43 ms
52,480 KB
testcase_04 AC 47 ms
52,224 KB
testcase_05 AC 43 ms
51,968 KB
testcase_06 AC 52 ms
60,544 KB
testcase_07 AC 42 ms
52,224 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 126 ms
68,224 KB
testcase_16 AC 165 ms
70,272 KB
testcase_17 AC 169 ms
70,528 KB
testcase_18 AC 171 ms
70,656 KB
testcase_19 AC 171 ms
70,528 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 222 ms
79,232 KB
testcase_31 AC 218 ms
79,488 KB
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
testcase_46 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#嘘

INF = 10 ** 18

N, M, K = map(int,input().split())

assert (1 <= N <= 200 and K <= 5 and 1 <= K <= M <= N * (N - 1) // 2)

dist = [[0 if i == j else INF for i in range(N)] for j in range(N)]

R = list(map(int,input().split()))
points = []
nes_cost = 0
check_set = set()
for i in range(M):
    A, B, C = map(int,input().split())
    assert(1 <= C <= 10 ** 4 and 1 <= A <= N and 1 <= B <= N and A != B)
    assert((A, B) not in check_set and (B, A) not in check_set)
    if i + 1 in R:
        nes_cost += C
        points.append((A - 1, B - 1))


    check_set.add((A, B))
    dist[A - 1][B - 1] = C
    dist[B - 1][A - 1] = C

for k in range(N):
    for i in range(N):
        for j in range(N):
            dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j])
for i in range(N):
    for j in range(N):
        assert(dist[i][j] < INF)


import itertools
ans = INF
for v in itertools.permutations(points):
    for i in range(2 ** K):
        now = 0
        now_cost = 0
        for j in range(K):
            x, y = v[j]
            if 1 & (i >> j):
                now_cost += dist[now][x] + dist[x][y]
                now = y
            else:
                now_cost += dist[now][y] + dist[y][x]
                now = x
        now_cost += dist[now][N - 1]
        
        ans = min(ans, now_cost)
print(ans)


0