結果

問題 No.1067 #いろいろな色 / Red and Blue and more various colors (Middle)
ユーザー aaaaaaaaaa2230aaaaaaaaaa2230
提出日時 2022-03-22 22:43:57
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 948 ms / 2,000 ms
コード長 706 bytes
コンパイル時間 306 ms
コンパイル使用メモリ 82,296 KB
実行使用メモリ 360,400 KB
最終ジャッジ日時 2024-04-18 23:35:32
合計ジャッジ時間 8,884 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
52,224 KB
testcase_01 AC 50 ms
63,104 KB
testcase_02 AC 53 ms
65,664 KB
testcase_03 AC 39 ms
56,960 KB
testcase_04 AC 56 ms
67,712 KB
testcase_05 AC 52 ms
66,816 KB
testcase_06 AC 51 ms
64,000 KB
testcase_07 AC 49 ms
64,256 KB
testcase_08 AC 49 ms
62,592 KB
testcase_09 AC 47 ms
62,592 KB
testcase_10 AC 49 ms
62,976 KB
testcase_11 AC 596 ms
253,696 KB
testcase_12 AC 443 ms
182,820 KB
testcase_13 AC 738 ms
325,256 KB
testcase_14 AC 423 ms
212,832 KB
testcase_15 AC 244 ms
129,048 KB
testcase_16 AC 245 ms
117,360 KB
testcase_17 AC 106 ms
84,336 KB
testcase_18 AC 503 ms
219,264 KB
testcase_19 AC 446 ms
227,684 KB
testcase_20 AC 295 ms
133,424 KB
testcase_21 AC 872 ms
360,400 KB
testcase_22 AC 919 ms
360,220 KB
testcase_23 AC 948 ms
360,064 KB
testcase_24 AC 41 ms
52,264 KB
testcase_25 AC 38 ms
54,120 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import bisect
from itertools import count

n,q = map(int,input().split())
A = list(map(int,input().split()))
Q = [list(map(int,input().split())) for i in range(q)]
A.sort()
mod = 998244353

dp = [[0]*(n+1) for i in range(n+1)]
dp[n][0] = 1
for i in range(n)[::-1]:
    a = A[i]
    for j in range(n+1):
        if dp[i+1][j] == 0:
            continue
        dp[i][j] += dp[i+1][j]*(a-1)%mod
        dp[i][j] %= mod
        dp[i][j+1] += dp[i+1][j]
        dp[i][j+1] %= mod

cumA = [1]
for a in A:
    cumA.append(cumA[-1]*a%mod)

for l,r,p in Q:
    ans = 0
    for i in range(l,r+1):
        ind = bisect.bisect_left(A,i)
        count = cumA[ind]*dp[ind][p]%mod
        ans ^= count
    print(ans%mod)
0