結果
| 問題 |
No.1067 #いろいろな色 / Red and Blue and more various colors (Middle)
|
| ユーザー |
|
| 提出日時 | 2020-08-11 14:00:46 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 481 ms / 2,000 ms |
| コード長 | 966 bytes |
| コンパイル時間 | 2,222 ms |
| コンパイル使用メモリ | 199,096 KB |
| 最終ジャッジ日時 | 2025-01-12 20:15:31 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 25 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
const int64_t MOD = 998244353;
void add(int64_t& a, int64_t b){
a = (a+b) % MOD;
}
void mul(int64_t& a, int64_t b){
a = a*b % MOD;
}
int main(){
int N, Q;
cin >> N >> Q;
vector<int> A(N);
for(int i=0; i<N; i++) cin >> A[i];
sort(A.begin(), A.end());
vector<int64_t> prod(N+1, 1);
for(int i=0; i<N; i++) prod[i+1] = prod[i] * A[i] % MOD;
static int64_t dp[6001][6001];
dp[N][0] = 1;
for(int i=N-1; i>=0; i--) for(int j=0; j<N; j++){
add(dp[i][j+1], dp[i+1][j]);
add(dp[i][j], (A[i]-1)*dp[i+1][j]);
}
while(Q--){
int l, r, p;
cin >> l >> r >> p;
int64_t ans = 0;
for(int c=l; c<=r; c++){
int x = lower_bound(A.begin(), A.end(), c) - A.begin();
int64_t res = prod[x] * dp[x][p] % MOD;
ans ^= res;
}
ans %= MOD;
cout << ans << endl;
}
return 0;
}