結果

問題 No.1067 #いろいろな色 / Red and Blue and more various colors (Middle)
ユーザー H3PO4H3PO4
提出日時 2020-05-29 22:44:16
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,097 ms / 2,000 ms
コード長 678 bytes
コンパイル時間 202 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 359,808 KB
最終ジャッジ日時 2024-04-24 00:11:47
合計ジャッジ時間 10,050 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 43 ms
52,224 KB
testcase_01 AC 61 ms
64,128 KB
testcase_02 AC 59 ms
65,152 KB
testcase_03 AC 39 ms
52,736 KB
testcase_04 AC 60 ms
67,712 KB
testcase_05 AC 61 ms
67,200 KB
testcase_06 AC 54 ms
63,872 KB
testcase_07 AC 60 ms
65,536 KB
testcase_08 AC 52 ms
62,976 KB
testcase_09 AC 51 ms
63,360 KB
testcase_10 AC 52 ms
62,592 KB
testcase_11 AC 690 ms
253,568 KB
testcase_12 AC 491 ms
182,912 KB
testcase_13 AC 898 ms
325,504 KB
testcase_14 AC 513 ms
212,992 KB
testcase_15 AC 269 ms
129,408 KB
testcase_16 AC 273 ms
117,104 KB
testcase_17 AC 117 ms
84,992 KB
testcase_18 AC 541 ms
219,136 KB
testcase_19 AC 556 ms
227,968 KB
testcase_20 AC 369 ms
133,120 KB
testcase_21 AC 1,097 ms
359,680 KB
testcase_22 AC 1,074 ms
359,680 KB
testcase_23 AC 1,061 ms
359,808 KB
testcase_24 AC 38 ms
52,480 KB
testcase_25 AC 38 ms
52,352 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import bisect

N, Q = map(int, input().split())
A = sorted(list(map(int, input().split())), reverse=True)
MOD = 998244353

dp = [[0] * (N + 2) for _ in range(N + 1)]
dp[0][1] = 1
for i, a in enumerate(A):
    for j in range(1, N + 2):
        dp[i + 1][j] += dp[i][j] * (a - 1) + dp[i][j - 1]
        dp[i + 1][j] %= MOD

t = 1
for i, a in enumerate(reversed(A)):
    t = (t * a) % MOD
    for j in range(N + 2):
        dp[N - 1 - i][j] = dp[N - 1 - i][j] * t % MOD


Am = [-a for a in A]
for _ in range(Q):
    l, r, p = map(int, input().split())
    ans = 0
    for i in range(l, r + 1):
        y = bisect.bisect_right(Am, -i)
        ans ^= dp[y][p+1]
    print(ans % MOD)
0