結果
問題 | No.1780 [Cherry Anniversary] 真冬に咲く26の櫻の木 |
ユーザー | mkawa2 |
提出日時 | 2021-12-09 02:23:52 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,912 bytes |
コンパイル時間 | 168 ms |
コンパイル使用メモリ | 82,464 KB |
実行使用メモリ | 77,940 KB |
最終ジャッジ日時 | 2024-07-16 13:06:22 |
合計ジャッジ時間 | 11,700 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 65 ms
70,944 KB |
testcase_01 | AC | 92 ms
75,856 KB |
testcase_02 | AC | 164 ms
77,392 KB |
testcase_03 | AC | 184 ms
76,656 KB |
testcase_04 | AC | 159 ms
77,144 KB |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | AC | 157 ms
76,728 KB |
testcase_08 | AC | 164 ms
77,004 KB |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | AC | 128 ms
76,260 KB |
testcase_14 | AC | 254 ms
77,624 KB |
testcase_15 | AC | 388 ms
77,316 KB |
testcase_16 | AC | 332 ms
77,340 KB |
testcase_17 | AC | 250 ms
77,148 KB |
testcase_18 | AC | 290 ms
76,980 KB |
testcase_19 | AC | 259 ms
77,084 KB |
testcase_20 | AC | 313 ms
77,396 KB |
testcase_21 | AC | 409 ms
77,180 KB |
testcase_22 | AC | 453 ms
77,144 KB |
testcase_23 | AC | 286 ms
76,936 KB |
testcase_24 | AC | 418 ms
77,320 KB |
testcase_25 | AC | 254 ms
76,948 KB |
testcase_26 | AC | 259 ms
77,312 KB |
testcase_27 | AC | 305 ms
77,320 KB |
testcase_28 | AC | 248 ms
77,252 KB |
testcase_29 | AC | 241 ms
77,196 KB |
testcase_30 | AC | 364 ms
77,276 KB |
testcase_31 | AC | 232 ms
77,748 KB |
testcase_32 | AC | 228 ms
77,644 KB |
testcase_33 | AC | 284 ms
76,924 KB |
testcase_34 | AC | 41 ms
59,988 KB |
testcase_35 | AC | 354 ms
76,624 KB |
testcase_36 | AC | 56 ms
60,956 KB |
testcase_37 | AC | 305 ms
76,532 KB |
testcase_38 | WA | - |
testcase_39 | AC | 246 ms
77,072 KB |
testcase_40 | AC | 241 ms
76,920 KB |
testcase_41 | AC | 231 ms
76,652 KB |
ソースコード
import sys sys.setrecursionlimit(200005) int1 = lambda x: int(x)-1 pDB = lambda *x: print(*x, end="\n", file=sys.stderr) p2D = lambda x: print(*x, sep="\n", end="\n\n", file=sys.stderr) def II(): return int(sys.stdin.readline()) def LI(): return list(map(int, sys.stdin.readline().split())) def LLI(rows_number): return [LI() for _ in range(rows_number)] def LI1(): return list(map(int1, sys.stdin.readline().split())) def LLI1(rows_number): return [LI1() for _ in range(rows_number)] def SI(): return sys.stdin.readline().rstrip() dij = [(0, 1), (-1, 0), (0, -1), (1, 0)] # dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)] inf = 18446744073709551615 # inf = 4294967295 # md = 10**9+7 # md = 998244353 md = 10**8+9 def dot(aa, bb): h = len(aa) w = len(bb[0]) res = [[0]*w for _ in range(h)] for i, row in enumerate(aa): for j, col in enumerate(zip(*bb)): v = -inf for a, b in zip(row, col): cur = a+b if cur > v: v = cur res[i][j] = v return res def matpow(mat, e): n = len(mat) res = [[0 if i == j else -inf for j in range(n)] for i in range(n)] while e: if e & 1: res = dot(res, mat) mat = dot(mat, mat) e >>= 1 return res cc = LI1() kk = LI() n = II() ee = [[[-inf]*16 for _ in range(16)] for _ in range(26)] for f, c in enumerate(cc): ee[f][c][c] = 0 for _ in range(n): s, a, b, e = SI().split() a = int1(a) b = int1(b) e = int(e) for c in s: c = ord(c)-65 ee[c][a][b] = ee[c][b][a] = max(ee[c][a][b], e) # p2D(ee) ss = [0]*16 for f in range(26): c = cc[f] eef = ee[f] eef = matpow(eef, kk[f]) # p2D(eef) for i, e in enumerate(eef[c]): if e == -inf: ss[i] = -inf else: ss[i] += e ans = max(ss) if ans == -inf: ans = "Impossible" print(ans)