結果

問題 No.2783 4-33 Easy
ユーザー rlangevin
提出日時 2024-06-14 21:45:16
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 203 ms / 2,000 ms
コード長 1,016 bytes
コンパイル時間 305 ms
コンパイル使用メモリ 81,920 KB
実行使用メモリ 77,572 KB
最終ジャッジ日時 2024-06-14 21:45:23
合計ジャッジ時間 6,087 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 26
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
A = list(map(int, input().split()))
B = input().split()
D = []
AA, BB = [], []
for a, b in zip(A, B):
    if b[-1] == "X":
        if len(b) == 1:
            D.append((a, 0))
        # else:
        #     b = int(b[:-1])
        #     if 
        #     D.append((a, ))
    else:
        AA.append(a)
        BB.append(int(b))
        
NA, NB, NC = 4, 33, 8
M = len(AA)
pre = [[[0] * (NB + 1) for _ in range(NA + 1)] for _ in range(NC + 1)]
pre[0][0][0] = 1
mod = 998244353
for i in range(M):
    dp = [[[0] * (NB + 1) for _ in range(NA + 1)] for _ in range(NC + 1)]
    aa, bb = AA[i], BB[i] 
    for a in range(NA + 1):
        for b in range(NB + 1):
            for c in range(NC + 1):
                dp[c][a][b] += pre[c][a][b]
                if a - aa >= 0 and b - bb >= 0 and c:
                    dp[c][a][b] += pre[c - 1][a - aa][b - bb]
                dp[c][a][b] %= mod
    pre, dp = dp, pre
    
ans = 0
for a, b in D:
    ans += pre[8][NA - a][NB - b]
    ans %= mod
    
print(ans)
0