結果
| 問題 |
No.1067 #いろいろな色 / Red and Blue and more various colors (Middle)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-05-29 22:12:38 |
| 言語 | PyPy2 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 797 ms / 2,000 ms |
| コード長 | 1,421 bytes |
| コンパイル時間 | 1,586 ms |
| コンパイル使用メモリ | 76,804 KB |
| 実行使用メモリ | 227,580 KB |
| 最終ジャッジ日時 | 2024-11-06 05:07:08 |
| 合計ジャッジ時間 | 10,291 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 25 |
ソースコード
FAST_IO = 1
if FAST_IO:
import io, sys, atexit
rr = iter(sys.stdin.read().splitlines()).next
sys.stdout = _OUTPUT_BUFFER = io.BytesIO()
@atexit.register
def write():
sys.__stdout__.write(_OUTPUT_BUFFER.getvalue())
else:
rr = raw_input
rri = lambda: int(rr())
rrm = lambda: map(int, rr().split())
####
from collections import defaultdict as ddic
N,Q = rrm()
A = rrm()
A.sort()
MOD = 998244353
poly = [1] # reverse order, MSB -> LSB
for i, c in enumerate(A): A[i] -= 1
for a in A:
# multiply by x + a
poly.append(0)
for i in xrange(len(poly) - 2, -1, -1):
poly[i+1] += a * poly[i]
poly[i+1] %= MOD
poly[0] %= MOD
polys = [poly[:]]
for a in A:
# Divide by x + a
quot = []
for i in xrange(len(poly) - 1):
coeff = poly[i]
quot.append(coeff)
poly[i+1] -= a * coeff % MOD
poly[i+1] %= MOD
poly = quot
# multiply by a + 1
#poly.append(0)
for i in xrange(len(poly)):
poly[i] *= a+1
poly[i] %= MOD
polys.append(poly[:])
#print("!", polys)
#print(len(polys))
for _ in xrange(Q):
l, r, p = rrm()
i = 0 # index of polys[]
bns = 0
#print("!", [row[~p] for row in polys])
for c in xrange(l, r+1):
while i+1 < len(polys) and c > A[i]+1:
i += 1
try:
bns ^= polys[i][~p]
except:
pass
print bns