結果
問題 | No.1067 #いろいろな色 / Red and Blue and more various colors (Middle) |
ユーザー |
![]() |
提出日時 | 2020-05-29 22:50:50 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 1,392 ms / 2,000 ms |
コード長 | 713 bytes |
コンパイル時間 | 527 ms |
コンパイル使用メモリ | 12,160 KB |
実行使用メモリ | 312,932 KB |
最終ジャッジ日時 | 2025-04-20 02:26:47 |
合計ジャッジ時間 | 19,720 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 25 |
ソースコード
import sys import numpy as np read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines MOD = 998244353 N, Q = map(int, readline().split()) A = np.array(readline().split(), np.int64) Q = readlines() A.sort() P = np.zeros((N + 1, N + 1), np.int64) x = 1 for a in A: x *= a x %= MOD P[-1, 0] = x for n in range(N - 1, -1, -1): a = A[n] inv = pow(int(a), MOD - 2, MOD) P[n] = P[n + 1] * (a - 1) P[n, 1:] += P[n + 1, :-1] P[n] %= MOD P[n] *= inv P[n] %= MOD for query in Q: L, R, p = map(int, query.split()) i = np.arange(L, R + 1) j = np.searchsorted(A, i) nums = P[j, p] print(np.bitwise_xor.reduce(nums))