結果

問題 No.1067 #いろいろな色 / Red and Blue and more various colors (Middle)
ユーザー H3PO4H3PO4
提出日時 2020-05-29 23:16:00
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 626 bytes
コンパイル時間 138 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 325,508 KB
最終ジャッジ日時 2024-04-24 01:15:48
合計ジャッジ時間 26,890 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 479 ms
44,268 KB
testcase_01 AC 478 ms
44,352 KB
testcase_02 AC 496 ms
44,096 KB
testcase_03 AC 484 ms
44,352 KB
testcase_04 AC 504 ms
44,228 KB
testcase_05 AC 506 ms
43,956 KB
testcase_06 AC 500 ms
44,088 KB
testcase_07 AC 498 ms
43,964 KB
testcase_08 AC 497 ms
44,356 KB
testcase_09 AC 509 ms
44,348 KB
testcase_10 AC 495 ms
44,348 KB
testcase_11 AC 1,556 ms
220,220 KB
testcase_12 AC 1,378 ms
148,840 KB
testcase_13 AC 1,645 ms
291,164 KB
testcase_14 AC 1,087 ms
179,388 KB
testcase_15 AC 808 ms
95,804 KB
testcase_16 AC 925 ms
83,900 KB
testcase_17 AC 543 ms
51,360 KB
testcase_18 AC 1,218 ms
185,528 KB
testcase_19 AC 1,134 ms
194,440 KB
testcase_20 AC 1,060 ms
99,652 KB
testcase_21 TLE -
testcase_22 TLE -
testcase_23 TLE -
testcase_24 AC 498 ms
44,484 KB
testcase_25 AC 489 ms
43,968 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import numpy as np
import bisect

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

dp = np.zeros((N + 1, N + 2), dtype=np.int64)
dp[0, 1] = 1
for i, a in enumerate(A):
    dp[i + 1][1:] = dp[i][1:] * (a - 1) + dp[i][:-1]
    dp[i + 1] %= MOD

t = 1
for i, a in enumerate(reversed(A)):
    t = (t * a) % MOD
    dp[N - 1 - i] *= t
    dp[N - 1 - i] %= 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