結果
問題 | No.1066 #いろいろな色 / Red and Blue and more various colors (Easy) |
ユーザー |
![]() |
提出日時 | 2020-05-29 21:49:46 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
TLE
|
実行時間 | - |
コード長 | 679 bytes |
コンパイル時間 | 356 ms |
コンパイル使用メモリ | 12,928 KB |
実行使用メモリ | 18,084 KB |
最終ジャッジ日時 | 2024-11-06 03:46:13 |
合計ジャッジ時間 | 3,976 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 5 TLE * 1 -- * 18 |
ソースコード
import sys readline = sys.stdin.readline ns = lambda: readline().rstrip() ni = lambda: int(readline().rstrip()) nm = lambda: map(int, readline().split()) nl = lambda: list(map(int, readline().split())) def solve(): mod = 998244353 n, q = nm() a = nl() b = nl() dp = [[0]*(n+2) for i in range(2)] dp[0][0] = 1 for i in range(n): v = i & 1 for j in range(n+1): if dp[v][j]: dp[v^1][j+1] = (dp[v^1][j+1] + dp[v][j]) % mod dp[v^1][j] = (dp[v^1][j] + (a[i] - 1) * dp[v][j]) % mod dp[v][j] = 0 # print(dp[v^1]) for x in b: print(dp[n&1][x]) return solve()