結果
問題 | No.2807 Have Another Go (Easy) |
ユーザー |
![]() |
提出日時 | 2025-06-12 15:37:46 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,549 bytes |
コンパイル時間 | 182 ms |
コンパイル使用メモリ | 82,616 KB |
実行使用メモリ | 271,824 KB |
最終ジャッジ日時 | 2025-06-12 15:38:28 |
合計ジャッジ時間 | 4,908 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 1 TLE * 1 -- * 44 |
ソースコード
MOD = 998244353 def main(): import sys input = sys.stdin.read data = input().split() idx = 0 N = int(data[idx]); idx +=1 M = int(data[idx]); idx +=1 k = int(data[idx]); idx +=1 C = list(map(int, data[idx:idx+k])) max_s = 2 * N -1 C_s = [0] * (max_s + 1) C_s[0] = 1 for s in range(1, max_s +1): for d in range(1,7): if s - d >=0: C_s[s] += C_s[s -d] if C_s[s] >= MOD: C_s[s] -= MOD total =0 for s in range(2*N -6, 2*N): if s <0: continue cnt_d = s - (2*N) +7 if cnt_d <0: cnt_d =0 if cnt_d >6: cnt_d =6 total += C_s[s] * cnt_d total %= MOD for c in C: A = [0] * (max_s +1) A[0] = 1 for s in range(0, max_s +1): for d in range(1,7): new_s = s + d if new_s > max_s: continue new_r = (s % N + d) % N if new_r == c: continue if new_s ==0: continue A[new_s] = (A[new_s] + A[s]) % MOD D =0 for s in range(2*N -6, 2*N): if s <0 or s > max_s: continue cnt_d = s - (2*N) +7 if cnt_d <0 or cnt_d >6: continue D = (D + A[s] * cnt_d) % MOD ans = (total - D) % MOD print(ans) if __name__ == '__main__': main()