結果

問題 No.1067 #いろいろな色 / Red and Blue and more various colors (Middle)
ユーザー NoneNone
提出日時 2021-04-28 23:38:28
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 711 ms / 2,000 ms
コード長 546 bytes
コンパイル時間 350 ms
コンパイル使用メモリ 86,908 KB
実行使用メモリ 360,824 KB
最終ジャッジ日時 2023-09-22 06:18:23
合計ジャッジ時間 9,180 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 80 ms
71,444 KB
testcase_01 AC 96 ms
76,356 KB
testcase_02 AC 94 ms
76,200 KB
testcase_03 AC 79 ms
74,800 KB
testcase_04 AC 91 ms
76,172 KB
testcase_05 AC 90 ms
76,268 KB
testcase_06 AC 89 ms
76,368 KB
testcase_07 AC 87 ms
76,188 KB
testcase_08 AC 88 ms
76,252 KB
testcase_09 AC 86 ms
76,368 KB
testcase_10 AC 86 ms
76,032 KB
testcase_11 AC 466 ms
254,344 KB
testcase_12 AC 376 ms
183,508 KB
testcase_13 AC 550 ms
326,336 KB
testcase_14 AC 349 ms
214,112 KB
testcase_15 AC 232 ms
131,220 KB
testcase_16 AC 249 ms
117,896 KB
testcase_17 AC 139 ms
85,952 KB
testcase_18 AC 391 ms
220,728 KB
testcase_19 AC 370 ms
228,880 KB
testcase_20 AC 291 ms
134,816 KB
testcase_21 AC 710 ms
360,032 KB
testcase_22 AC 711 ms
360,824 KB
testcase_23 AC 704 ms
360,648 KB
testcase_24 AC 76 ms
71,516 KB
testcase_25 AC 75 ms
71,120 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from bisect import *
MOD=998244353
N,Q=map(int, input().split())
A=list(map(int, input().split()))
A.sort()
dp=[[0]*(N+1) for _ in range(N)]
dp[N-1][0]=A[N-1]-1
dp[N-1][1]=1
for r in range(N-1)[::-1]:
    for k in range(N-r+1):
        dp[r][k]=dp[r+1][k]*(A[r]-1)+dp[r+1][k-1]
        dp[r][k]%=MOD
dp2=[1]*(N+1)
for l in range(N):
    dp2[l]=A[l]*dp2[l-1]
    dp2[l]%=MOD
for _ in range(Q):
    l,r,p=map(int, input().split())
    res=0
    for i in range(l,r+1):
        j=bisect_left(A,i)
        res^=dp2[j-1]*dp[j][p]%MOD
    print(res%MOD)
0