結果
| 問題 |
No.1067 #いろいろな色 / Red and Blue and more various colors (Middle)
|
| コンテスト | |
| ユーザー |
tamato
|
| 提出日時 | 2020-05-29 22:11:56 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 942 ms / 2,000 ms |
| コード長 | 1,045 bytes |
| コンパイル時間 | 163 ms |
| コンパイル使用メモリ | 82,652 KB |
| 実行使用メモリ | 359,640 KB |
| 最終ジャッジ日時 | 2024-11-06 05:05:52 |
| 合計ジャッジ時間 | 8,851 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 25 |
ソースコード
mod = 998244353
eps = 10**-9
def main():
import sys
from bisect import bisect_left
input = sys.stdin.readline
N, Q = map(int, input().split())
A = list(map(int, input().split()))
A.sort(reverse=True)
cm = [1] * N
cm[-1] = A[-1]
for i in range(N-2, -1, -1):
cm[i] = (cm[i+1] * A[i])%mod
dp = [[0] * (N + 1) for _ in range(N + 1)]
dp[0][0] = 1
for i in range(N):
a = A[i]
for j in range(N + 1):
if dp[i][j] == 0:
continue
dp[i + 1][j] = (dp[i + 1][j] + dp[i][j] * (a - 1)) % mod
if j + 1 <= N:
dp[i + 1][j + 1] = (dp[i + 1][j + 1] + dp[i][j]) % mod
A.reverse()
for _ in range(Q):
l, r, p = map(int, input().split())
ans = 0
for i in range(l, r+1):
j = bisect_left(A, i)
tmp = dp[N - j][p]
if j > 0:
tmp = (tmp * cm[-j])%mod
ans = (ans ^ tmp)%mod
print(ans)
if __name__ == '__main__':
main()
tamato