結果
問題 | No.2964 Obstruction Bingo |
ユーザー | ArcAki |
提出日時 | 2024-11-16 17:25:51 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,818 bytes |
コンパイル時間 | 831 ms |
コンパイル使用メモリ | 82,000 KB |
実行使用メモリ | 156,928 KB |
最終ジャッジ日時 | 2024-11-16 17:27:27 |
合計ジャッジ時間 | 95,250 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 52 ms
66,176 KB |
testcase_01 | AC | 58 ms
142,336 KB |
testcase_02 | AC | 88 ms
80,696 KB |
testcase_03 | AC | 58 ms
69,248 KB |
testcase_04 | AC | 57 ms
69,120 KB |
testcase_05 | AC | 451 ms
156,672 KB |
testcase_06 | AC | 1,039 ms
83,456 KB |
testcase_07 | AC | 210 ms
155,956 KB |
testcase_08 | AC | 966 ms
83,456 KB |
testcase_09 | AC | 601 ms
156,928 KB |
testcase_10 | AC | 1,293 ms
84,096 KB |
testcase_11 | AC | 424 ms
156,020 KB |
testcase_12 | AC | 1,545 ms
83,712 KB |
testcase_13 | AC | 678 ms
156,768 KB |
testcase_14 | AC | 1,050 ms
83,840 KB |
testcase_15 | AC | 225 ms
155,828 KB |
testcase_16 | AC | 373 ms
83,072 KB |
testcase_17 | AC | 270 ms
156,228 KB |
testcase_18 | AC | 567 ms
83,456 KB |
testcase_19 | AC | 324 ms
155,984 KB |
testcase_20 | AC | 1,074 ms
83,328 KB |
testcase_21 | AC | 1,184 ms
156,660 KB |
testcase_22 | AC | 204 ms
82,176 KB |
testcase_23 | AC | 139 ms
156,032 KB |
testcase_24 | AC | 108 ms
82,304 KB |
testcase_25 | TLE | - |
testcase_26 | TLE | - |
testcase_27 | TLE | - |
testcase_28 | TLE | - |
testcase_29 | TLE | - |
testcase_30 | TLE | - |
testcase_31 | TLE | - |
testcase_32 | TLE | - |
testcase_33 | TLE | - |
testcase_34 | TLE | - |
testcase_35 | TLE | - |
testcase_36 | TLE | - |
testcase_37 | TLE | - |
testcase_38 | TLE | - |
testcase_39 | TLE | - |
testcase_40 | TLE | - |
testcase_41 | TLE | - |
testcase_42 | TLE | - |
testcase_43 | TLE | - |
testcase_44 | TLE | - |
testcase_45 | AC | 1,034 ms
78,520 KB |
testcase_46 | AC | 673 ms
78,692 KB |
testcase_47 | AC | 677 ms
78,592 KB |
testcase_48 | AC | 1,152 ms
78,720 KB |
testcase_49 | AC | 1,086 ms
78,808 KB |
testcase_50 | AC | 1,517 ms
78,976 KB |
testcase_51 | TLE | - |
ソースコード
from collections import deque, defaultdict as dd from copy import deepcopy from heapq import heappop, heappush, heappushpop, heapify INF = 1 << 60 MOD = 998244353 def fast_mod_pow(x, p, m): res = 1 t = x z = p while z > 0: if z % 2 == 1: res = (res * t) % m t = (t * t) % m z //= 2 return res def extended_gcd(a, b): if b == 0: return a, 1, 0 else: g, x, y = extended_gcd(b, a % b) return g, y, x - (a // b) * y def mod_inverse(a, m): _, x, _ = extended_gcd(a, m) return (x % m + m) % m def main(): l, k = map(int, input().split()) s = list(input()) t = list(input()) a = list(map(int, input().split())) ac = sum(a) div = mod_inverse(ac, MOD) for i in range(26): a[i] = (a[i]*div)%MOD z = ord("a") for i in range(l): s[i] = ord(s[i])-z t[i] = ord(t[i])-z dp = [[0 for _ in range(k+2)]for _ in range(k+2)] dp[0][0] = 1 for _ in range(k): for i in range(k, -1, -1): for j in range(k, -1, -1): if abs(i-j) >= l: continue if s[i%l]==t[j%l]: dp[i+1][j+1] = (dp[i+1][j+1]+dp[i][j]*a[s[i%l]])%MOD dp[i][j] = (dp[i][j]*(MOD+1-a[s[i%l]])%MOD)%MOD else: dp[i+1][j] = (dp[i+1][j]+dp[i][j]*a[s[i%l]])%MOD dp[i][j+1] = (dp[i][j+1]+dp[i][j]*a[t[j%l]])%MOD dp[i][j] = (dp[i][j]*(2*MOD+1-a[s[i%l]]-a[t[j%l]]))%MOD ans1, ans2 = 0, 0 for i in range(k+2): for j in range(k+2): if i+l <= j: ans2 = (ans2+dp[i][j])%MOD elif i >= l+j: ans1 = (ans1+dp[i][j])%MOD print(ans1, ans2) if __name__ == "__main__": main()