結果
問題 | No.1067 #いろいろな色 / Red and Blue and more various colors (Middle) |
ユーザー |
|
提出日時 | 2020-05-30 14:00:40 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,130 bytes |
コンパイル時間 | 1,724 ms |
コンパイル使用メモリ | 175,964 KB |
実行使用メモリ | 284,928 KB |
最終ジャッジ日時 | 2024-11-07 15:52:00 |
合計ジャッジ時間 | 5,873 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 5 WA * 20 |
ソースコード
#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) - A.begin(); if (N - x + 1 < P) break; if (x == 0) ans ^= dp[N - P][0]; else ans ^= (cumprd[x - 1] * dp[N - P - x + 1][x - 1] % MOD); } ans %= MOD; cout << ans << endl; } }