結果

問題 No.1066 #いろいろな色 / Red and Blue and more various colors (Easy)
ユーザー uni_pythonuni_python
提出日時 2020-10-07 23:03:17
言語 Python3
(3.11.6 + numpy 1.26.0 + scipy 1.11.3)
結果
MLE  
実行時間 -
コード長 669 bytes
コンパイル時間 239 ms
コンパイル使用メモリ 10,792 KB
実行使用メモリ 295,960 KB
最終ジャッジ日時 2023-09-27 10:09:48
合計ジャッジ時間 4,241 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
12,136 KB
testcase_01 AC 16 ms
7,920 KB
testcase_02 AC 16 ms
7,788 KB
testcase_03 AC 16 ms
7,916 KB
testcase_04 AC 16 ms
7,752 KB
testcase_05 AC 16 ms
7,804 KB
testcase_06 AC 16 ms
7,792 KB
testcase_07 AC 16 ms
7,792 KB
testcase_08 MLE -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input=sys.stdin.readline
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=998244353
    N,Q=MI()
    A=LI()
    B=LI()
    
    dp=[[0]*(N+1)for _ in range(N+1)]
    # dp[i][j]はiまで見て,j個だけ色1の玉を持つ
    
    dp[0][0]=1
    for i in range(N):
        dp[i+1][0]=(dp[i][0] * (A[i]-1) )%mod
    
    for i in range(N):
        for j in range(N):
            dp[i+1][j+1]=(
                dp[i][j]+
                dp[i][j+1]*(A[i]-1)
            )%mod
            
    for i in range(Q):
        j=B[i]
        print(dp[-1][j])
    


main()
0