結果
問題 | No.2783 4-33 Easy |
ユーザー | LyricalMaestro |
提出日時 | 2024-10-20 18:40:43 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 229 ms / 2,000 ms |
コード長 | 2,135 bytes |
コンパイル時間 | 445 ms |
コンパイル使用メモリ | 82,420 KB |
実行使用メモリ | 77,260 KB |
最終ジャッジ日時 | 2024-10-20 18:40:50 |
合計ジャッジ時間 | 7,127 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 52 ms
66,120 KB |
testcase_01 | AC | 62 ms
72,416 KB |
testcase_02 | AC | 68 ms
73,444 KB |
testcase_03 | AC | 61 ms
69,884 KB |
testcase_04 | AC | 167 ms
76,972 KB |
testcase_05 | AC | 187 ms
76,728 KB |
testcase_06 | AC | 181 ms
76,508 KB |
testcase_07 | AC | 180 ms
76,376 KB |
testcase_08 | AC | 186 ms
76,884 KB |
testcase_09 | AC | 195 ms
76,864 KB |
testcase_10 | AC | 191 ms
76,736 KB |
testcase_11 | AC | 197 ms
76,592 KB |
testcase_12 | AC | 226 ms
76,820 KB |
testcase_13 | AC | 229 ms
76,732 KB |
testcase_14 | AC | 199 ms
76,688 KB |
testcase_15 | AC | 225 ms
76,740 KB |
testcase_16 | AC | 192 ms
76,724 KB |
testcase_17 | AC | 195 ms
76,816 KB |
testcase_18 | AC | 194 ms
76,896 KB |
testcase_19 | AC | 195 ms
76,692 KB |
testcase_20 | AC | 191 ms
77,096 KB |
testcase_21 | AC | 188 ms
76,860 KB |
testcase_22 | AC | 215 ms
77,260 KB |
testcase_23 | AC | 193 ms
76,804 KB |
testcase_24 | AC | 194 ms
77,236 KB |
testcase_25 | AC | 192 ms
76,896 KB |
testcase_26 | AC | 194 ms
77,072 KB |
testcase_27 | AC | 205 ms
76,608 KB |
testcase_28 | AC | 196 ms
76,856 KB |
ソースコード
## https://yukicoder.me/problems/no/2783 MOD = 998244353 def main(): N = int(input()) A = list(map(int, input().split())) B = input().split() # 8枚目を選ぶ dp = [[[0 for _ in range(34)] for _ in range(5)] for _ in range(9)] dp[0][0][0] = 1 for i in range(N): if "X" in B[i]: continue new_dp = [[[0 for _ in range(34)] for _ in range(5)] for _ in range(9)] a = A[i] b = int(B[i]) for n in range(9): for a_score in range(5): for b_score in range(34): # 選ばないケース new_dp[n][a_score][b_score] += dp[n][a_score][b_score] new_dp[n][a_score][b_score] %= MOD # 選ぶケース if n + 1 <= 8 and a + a_score <= 4 and b + b_score <= 33: if b == 0: new_dp[n + 1][a + a_score][b + b_score] += dp[n][a_score][b_score] new_dp[n + 1 ][a + a_score][b + b_score] %= MOD else: new_dp[n + 1][a + a_score][b + b_score] += dp[n][a_score][b_score] new_dp[n + 1 ][a + a_score][b + b_score] %= MOD dp = new_dp targets= [] for i in range(N): if "X" in B[i]: targets.append((A[i], B[i])) # 9枚目を選ぶ answer = 0 for a, b in targets: b_ = b[:-1] if len(b_) == 0: b_ = 0 else: b_ = int(b_) for a_score in range(5): for b_score in range(34): if a + a_score == 4 and b_ + b_score == 33: if b_ == 0: answer += dp[-1][a_score][b_score] answer %= MOD else: if a + a_score >= b_score + b_ - 4: answer += dp[-1][a_score][b_score] answer %= MOD print(answer) if __name__ == "__main__": main()