結果
問題 |
No.2807 Have Another Go (Easy)
|
ユーザー |
![]() |
提出日時 | 2025-06-12 18:26:21 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,308 bytes |
コンパイル時間 | 134 ms |
コンパイル使用メモリ | 82,256 KB |
実行使用メモリ | 271,988 KB |
最終ジャッジ日時 | 2025-06-12 18:26:50 |
合計ジャッジ時間 | 4,604 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 1 TLE * 1 -- * 44 |
ソースコード
MOD = 998244353 def main(): import sys input = sys.stdin.read().split() ptr = 0 N = int(input[ptr]); ptr +=1 M = int(input[ptr]); ptr +=1 k = int(input[ptr]); ptr +=1 Cs = list(map(int, input[ptr:ptr+k])) ptr +=k # Compute S target = 2 * N dp = [0] * (target + 6) # x can be up to target-1 +6 = target+5 dp[0] = 1 S = 0 for x in range(target): if dp[x] == 0: continue for d in range(1,7): nx = x + d if nx >= target: S = (S + dp[x]) % MOD else: dp[nx] = (dp[nx] + dp[x]) % MOD # Process each query for c in Cs: r = c % N # Compute A(r) dp_avoid = [0] * (target + 6) dp_avoid[0] = 1 A = 0 for x in range(target): if x % N == r: continue if dp_avoid[x] == 0: continue for d in range(1,7): nx = x + d if nx >= target: A = (A + dp_avoid[x]) % MOD else: if nx % N != r: dp_avoid[nx] = (dp_avoid[nx] + dp_avoid[x]) % MOD ans = (S - A) % MOD print(ans) if __name__ == '__main__': main()