結果
| 問題 |
No.1814 Uribo Road (Easy)
|
| ユーザー |
|
| 提出日時 | 2021-11-04 22:04:52 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,343 bytes |
| コンパイル時間 | 458 ms |
| コンパイル使用メモリ | 12,928 KB |
| 実行使用メモリ | 24,576 KB |
| 最終ジャッジ日時 | 2024-11-21 22:54:37 |
| 合計ジャッジ時間 | 67,867 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 3 |
| other | WA * 24 TLE * 20 |
ソースコード
#嘘
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):
print(dist[i])
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)