結果

問題 No.1067 #いろいろな色 / Red and Blue and more various colors (Middle)
ユーザー titiatitia
提出日時 2020-05-29 23:03:58
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 853 ms / 2,000 ms
コード長 599 bytes
コンパイル時間 855 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 360,192 KB
最終ジャッジ日時 2024-04-24 10:59:05
合計ジャッジ時間 8,363 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
51,968 KB
testcase_01 AC 52 ms
62,848 KB
testcase_02 AC 57 ms
65,280 KB
testcase_03 AC 41 ms
56,704 KB
testcase_04 AC 57 ms
66,944 KB
testcase_05 AC 53 ms
66,432 KB
testcase_06 AC 57 ms
63,488 KB
testcase_07 AC 53 ms
63,616 KB
testcase_08 AC 52 ms
62,592 KB
testcase_09 AC 53 ms
62,336 KB
testcase_10 AC 52 ms
62,336 KB
testcase_11 AC 538 ms
253,568 KB
testcase_12 AC 512 ms
182,784 KB
testcase_13 AC 668 ms
325,632 KB
testcase_14 AC 380 ms
213,108 KB
testcase_15 AC 216 ms
129,012 KB
testcase_16 AC 209 ms
116,992 KB
testcase_17 AC 96 ms
84,476 KB
testcase_18 AC 421 ms
219,256 KB
testcase_19 AC 404 ms
227,668 KB
testcase_20 AC 256 ms
133,376 KB
testcase_21 AC 839 ms
360,064 KB
testcase_22 AC 853 ms
360,192 KB
testcase_23 AC 768 ms
359,936 KB
testcase_24 AC 39 ms
51,968 KB
testcase_25 AC 37 ms
52,736 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

N,Q=map(int,input().split())
A=sorted(map(int,input().split()),reverse=True)
B=[list(map(int,input().split())) for i in range(Q)]

mod=998244353

DP=[[0]*(N+3) for i in range(N+1)]
DP[0][0]=1

for i in range(N):
    a=A[i]
    
    for j in range(N,-1,-1):
        DP[i+1][j]=(DP[i][j]*(a-1)+DP[i][j-1])%mod

#print(DP)

import bisect
AX=list(reversed(A))

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

KR.reverse()

for l,r,x in B:
    ANS=0
    for k in range(l,r+1):
        t=bisect.bisect_left(AX,k)

        ANS^=DP[N-t][x]*KR[N-t]%mod
    print(ANS)
0