結果
問題 |
No.3158 Collect Stamps
|
ユーザー |
![]() |
提出日時 | 2025-05-23 19:48:18 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,025 bytes |
コンパイル時間 | 3,276 ms |
コンパイル使用メモリ | 81,960 KB |
実行使用メモリ | 78,016 KB |
最終ジャッジ日時 | 2025-05-23 19:48:26 |
合計ジャッジ時間 | 4,848 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 20 WA * 15 |
ソースコード
import sys, time, random, heapq, math, itertools from collections import deque, Counter, defaultdict #from sortedcontainers import SortedSet, SortedList from bisect import bisect, bisect_left, bisect_right import heapq as hq from functools import cache, cmp_to_key def debug(*x):print('debug:',*x, file=sys.stderr) sys.setrecursionlimit(300000) input = lambda: sys.stdin.readline().rstrip() ii = lambda: int(input()) mi = lambda: map(int, input().split()) li = lambda: list(mi()) inf = 2 ** 61 - 1 mod = 998244353 N,M,K = mi() A = li() T = [li() for _ in range(N)] ans = inf for bit in range(1<<N): if bit.bit_count() != M: continue l = [] for i in range(N): if bit & (1<<i): l.append(i) for p in itertools.permutations(l): now = p[0] cnt = 0 for i in range(1,M): cnt += T[now][p[i]] now = p[i] last = inf for i in range(K): last = min(last, T[now][A[i]-1]) ans = min(ans,cnt) print(ans)