結果
問題 | No.1067 #いろいろな色 / Red and Blue and more various colors (Middle) |
ユーザー |
|
提出日時 | 2020-05-30 14:00:40 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.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 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,248 KB |
testcase_01 | WA | - |
testcase_02 | WA | - |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | AC | 405 ms
284,928 KB |
testcase_22 | AC | 396 ms
284,928 KB |
testcase_23 | AC | 403 ms
284,928 KB |
testcase_24 | AC | 3 ms
5,248 KB |
testcase_25 | AC | 3 ms
5,248 KB |
ソースコード
#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; } }