結果
| 問題 | No.1067 #いろいろな色 / Red and Blue and more various colors (Middle) | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2020-05-30 14:14:58 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 410 ms / 2,000 ms | 
| コード長 | 1,104 bytes | 
| コンパイル時間 | 1,944 ms | 
| コンパイル使用メモリ | 175,628 KB | 
| 実行使用メモリ | 284,928 KB | 
| 最終ジャッジ日時 | 2024-11-07 16:06:37 | 
| 合計ジャッジ時間 | 5,720 ms | 
| ジャッジサーバーID (参考情報) | judge3 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 1 | 
| other | AC * 25 | 
ソースコード
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i ++)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> PL;
typedef pair<int,int> P;
const int INF = 1e9;
const ll MOD = 998244353;
const double eps = 1e-6;
int main() {
    int N,Q; cin >> N >> Q;
    vector<ll> A(N);
    rep(i,N) {
        ll a; cin >> a; A[i] = a - 1;
    }
    sort(A.begin(),A.end());
    vector<ll> cumprd(N + 1,1);
    rep(i,N) cumprd[i + 1] = cumprd[i] * (A[i] + 1) % MOD;
    vector<vector<ll>> dp(N + 1,vector<ll>(N + 1,0));
    dp[0] = vector<ll>(N + 1,1);
    for (int i = 1;i < N + 1;i++) {
        for (int j = N - 1; j >= 0;j--) {
            dp[i][j] = (dp[i - 1][j + 1]*A[j] + dp[i][j + 1])%MOD;
        }
    }
    rep(_,Q) {
        ll L,R,P; cin >> L >> R >> P;
        ll ans = 0;
        for (int i = L;i <= R;i ++) {
            int x = lower_bound(A.begin(),A.end(),i - 1) - A.begin();
            if (x == 0) ans ^= dp[N - P][0];
            else if (N - x - P >= 0) ans ^= (cumprd[x] * dp[N - P - x][x] % MOD);
        }
        ans %= MOD;
        cout << ans << endl;
    }
}
            
            
            
        