結果
問題 | No.2807 Have Another Go (Easy) |
ユーザー | LyricalMaestro |
提出日時 | 2024-09-11 00:40:08 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 217 ms / 3,000 ms |
コード長 | 3,078 bytes |
コンパイル時間 | 406 ms |
コンパイル使用メモリ | 82,396 KB |
実行使用メモリ | 85,648 KB |
最終ジャッジ日時 | 2024-09-11 00:40:17 |
合計ジャッジ時間 | 9,445 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 38 ms
53,492 KB |
testcase_01 | AC | 168 ms
84,772 KB |
testcase_02 | AC | 171 ms
82,048 KB |
testcase_03 | AC | 162 ms
80,656 KB |
testcase_04 | AC | 65 ms
78,876 KB |
testcase_05 | AC | 179 ms
82,772 KB |
testcase_06 | AC | 199 ms
83,168 KB |
testcase_07 | AC | 141 ms
77,708 KB |
testcase_08 | AC | 141 ms
79,252 KB |
testcase_09 | AC | 148 ms
79,820 KB |
testcase_10 | AC | 157 ms
80,848 KB |
testcase_11 | AC | 187 ms
85,104 KB |
testcase_12 | AC | 189 ms
85,292 KB |
testcase_13 | AC | 190 ms
85,044 KB |
testcase_14 | AC | 192 ms
85,236 KB |
testcase_15 | AC | 194 ms
84,920 KB |
testcase_16 | AC | 216 ms
85,648 KB |
testcase_17 | AC | 192 ms
85,008 KB |
testcase_18 | AC | 188 ms
85,156 KB |
testcase_19 | AC | 191 ms
85,216 KB |
testcase_20 | AC | 188 ms
84,916 KB |
testcase_21 | AC | 189 ms
85,152 KB |
testcase_22 | AC | 217 ms
84,852 KB |
testcase_23 | AC | 191 ms
84,984 KB |
testcase_24 | AC | 190 ms
85,248 KB |
testcase_25 | AC | 191 ms
85,052 KB |
testcase_26 | AC | 194 ms
84,944 KB |
testcase_27 | AC | 190 ms
85,148 KB |
testcase_28 | AC | 191 ms
84,856 KB |
testcase_29 | AC | 188 ms
85,100 KB |
testcase_30 | AC | 190 ms
85,044 KB |
testcase_31 | AC | 44 ms
62,300 KB |
testcase_32 | AC | 64 ms
69,568 KB |
testcase_33 | AC | 83 ms
76,300 KB |
testcase_34 | AC | 60 ms
66,692 KB |
testcase_35 | AC | 44 ms
61,920 KB |
testcase_36 | AC | 148 ms
77,768 KB |
testcase_37 | AC | 138 ms
76,436 KB |
testcase_38 | AC | 164 ms
77,476 KB |
testcase_39 | AC | 104 ms
76,772 KB |
testcase_40 | AC | 156 ms
77,724 KB |
testcase_41 | AC | 167 ms
77,832 KB |
testcase_42 | AC | 171 ms
77,584 KB |
testcase_43 | AC | 155 ms
77,612 KB |
testcase_44 | AC | 184 ms
77,840 KB |
testcase_45 | AC | 153 ms
77,800 KB |
ソースコード
## https://yukicoder.me/problems/no/1331 MOD = 998244353 def solve(N, M, dp, c, total_value): dp1 = {} for j in range(1, 6): if c - j < 0: continue dp1[c - j] = dp[c - j] dp2 = {} for j in range(1, 6): if (c - j) in dp1: for k in range(1, 7): if (c - j + k) > c: if (c - j + k) not in dp2: dp2[(c - j + k)] = 0 dp2[(c - j + k)] += dp1[c - j] dp2[(c - j + k)] %= MOD dp3 = {} for key, value in dp2.items(): for j in range(1, 6): if N + c - j < key: continue if (N + c - j) not in dp3: dp3[(N + c - j)] = 0 dp3[(N + c - j)] += (value * dp[(N + c - j - key)])% MOD dp3[(N + c - j)] %= MOD dp4 = {} for j in range(1, 6): if (N + c - j) in dp3: for k in range(1, 7): if (N + c - j + k) >= N * M: continue elif (N + c - j + k) > N + c: if (N + c - j + k) not in dp4: dp4[(N + c - j + k)] = 0 dp4[(N + c - j + k)] += dp3[N + c - j] dp4[(N + c - j + k)] %= MOD dp5 = {} for key, value in dp4.items(): for j in range(1, 7): if 2 * N - j < key: continue if (2 * N - j) not in dp5: dp5[(2 * N - j)] = 0 dp5[(2 * N - j)] += (value * dp[(2 * N - j - key)])% MOD dp5[2 * N - j] %= MOD answer = 0 for key, value in dp5.items(): for j in range(1, 7): if key + j >= N * M: answer += value answer %= MOD for key, value in dp3.items(): for j in range(1, 7): if key + j >= N * M: answer += value answer %= MOD print((total_value - answer) % MOD) def solve2(N, M, c, total_value): dp = [0] * (N + M + 6) max_x = N * M + 6 dp = [0] * max_x dp[0] = 1 for i in range(N * M): for j in range(1, 7): if (i + j < N * M) and (i + j) % N == c: continue dp[i + j] += dp[i] dp[i + j] %= MOD total_value2 = 0 for j in range(6): total_value2 += dp[N * M + j] total_value2 %= MOD print((total_value - total_value2) % MOD) def main(): N, M, k = map(int, input().split()) C = list(map(int, input().split())) # 何も障害がない場合の回答を用意 max_x = N * M + 6 dp = [0] * max_x dp[0] = 1 for i in range(N * M): for j in range(1, 7): dp[i + j] += dp[i] dp[i + j] %= MOD total_value = 0 for j in range(6): total_value += dp[N * M + j] total_value %= MOD # 各C_iについて回答を用意 for c in C: solve(N, M, dp, c, total_value) # solve2(N, M, c, total_value) if __name__ == "__main__": main()