結果

問題 No.1067 #いろいろな色 / Red and Blue and more various colors (Middle)
ユーザー wattaiheiwattaihei
提出日時 2020-05-29 22:54:24
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 467 ms / 2,000 ms
コード長 699 bytes
コンパイル時間 184 ms
コンパイル使用メモリ 82,560 KB
実行使用メモリ 219,136 KB
最終ジャッジ日時 2024-04-24 00:31:13
合計ジャッジ時間 5,602 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
52,480 KB
testcase_01 AC 59 ms
63,616 KB
testcase_02 AC 67 ms
66,048 KB
testcase_03 AC 50 ms
57,344 KB
testcase_04 AC 66 ms
67,072 KB
testcase_05 AC 62 ms
67,072 KB
testcase_06 AC 63 ms
64,768 KB
testcase_07 AC 58 ms
64,128 KB
testcase_08 AC 57 ms
62,720 KB
testcase_09 AC 56 ms
62,720 KB
testcase_10 AC 56 ms
62,592 KB
testcase_11 AC 329 ms
165,760 KB
testcase_12 AC 293 ms
130,560 KB
testcase_13 AC 358 ms
201,472 KB
testcase_14 AC 227 ms
145,408 KB
testcase_15 AC 167 ms
103,168 KB
testcase_16 AC 191 ms
97,280 KB
testcase_17 AC 102 ms
80,640 KB
testcase_18 AC 270 ms
148,864 KB
testcase_19 AC 245 ms
152,960 KB
testcase_20 AC 231 ms
105,728 KB
testcase_21 AC 465 ms
219,136 KB
testcase_22 AC 467 ms
218,880 KB
testcase_23 AC 466 ms
218,880 KB
testcase_24 AC 43 ms
52,480 KB
testcase_25 AC 43 ms
52,096 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline
from bisect import bisect_left

mod = 998244353

N, Q = map(int, input().split())
A = list(map(int, input().split()))
Query = [list(map(int, input().split())) for _ in range(Q)]
A.sort(reverse=True)
B = A[::-1]

dp = [[1]]
for i, a in enumerate(A):
    ndp = [0]*(i+2)
    ndp[0] = dp[-1][0]*(a-1) % mod
    ndp[i+1] = 1
    for j in range(1, i+1):
        ndp[j] = (dp[-1][j]*(a-1) + dp[-1][j-1]) % mod
    dp.append(ndp)

C = [1]
for b in B:
    C.append(C[-1]*b%mod)

for l, r, p in Query:
    ans = 0
    for k in range(l, r+1):
        ma = N - bisect_left(B, k)
        if p < len(dp[ma]):
            ans ^= (dp[ma][p] * C[N-ma]) % mod
    print(ans%mod)
0