結果
問題 | No.1067 #いろいろな色 / Red and Blue and more various colors (Middle) |
ユーザー | iqueue02 |
提出日時 | 2020-05-31 11:20:55 |
言語 | C++17 (gcc 13.2.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 601 ms / 2,000 ms |
コード長 | 2,065 bytes |
コンパイル時間 | 3,604 ms |
コンパイル使用メモリ | 210,216 KB |
実行使用メモリ | 284,708 KB |
最終ジャッジ日時 | 2023-08-10 19:04:42 |
合計ジャッジ時間 | 9,554 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
4,380 KB |
testcase_01 | AC | 2 ms
4,380 KB |
testcase_02 | AC | 2 ms
4,380 KB |
testcase_03 | AC | 1 ms
4,376 KB |
testcase_04 | AC | 4 ms
4,380 KB |
testcase_05 | AC | 3 ms
4,380 KB |
testcase_06 | AC | 3 ms
4,380 KB |
testcase_07 | AC | 3 ms
4,376 KB |
testcase_08 | AC | 2 ms
4,380 KB |
testcase_09 | AC | 3 ms
4,384 KB |
testcase_10 | AC | 3 ms
4,380 KB |
testcase_11 | AC | 279 ms
179,316 KB |
testcase_12 | AC | 238 ms
108,368 KB |
testcase_13 | AC | 380 ms
250,860 KB |
testcase_14 | AC | 168 ms
139,012 KB |
testcase_15 | AC | 96 ms
54,984 KB |
testcase_16 | AC | 129 ms
42,972 KB |
testcase_17 | AC | 22 ms
10,476 KB |
testcase_18 | AC | 205 ms
145,336 KB |
testcase_19 | AC | 182 ms
153,884 KB |
testcase_20 | AC | 199 ms
59,324 KB |
testcase_21 | AC | 600 ms
284,668 KB |
testcase_22 | AC | 601 ms
284,708 KB |
testcase_23 | AC | 600 ms
284,708 KB |
testcase_24 | AC | 2 ms
4,380 KB |
testcase_25 | AC | 2 ms
4,384 KB |
ソースコード
#include <bits/stdc++.h> using namespace std; #define rep(i,n) for(int i = 0; i < (n);i++) #define sz(x) int(x.size()) typedef long long ll; typedef pair<int,int> P; constexpr int INF = 2e9; constexpr ll mod = 998244353; struct mint { ll x; // typedef long long ll; mint(ll x=0):x((x%mod+mod)%mod){} mint operator-() const { return mint(-x);} mint& operator+=(const mint a) { if ((x += a.x) >= mod) x -= mod; return *this; } mint& operator-=(const mint a) { if ((x += mod-a.x) >= mod) x -= mod; return *this; } mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;} mint operator+(const mint a) const { return mint(*this) += a;} mint operator-(const mint a) const { return mint(*this) -= a;} mint operator*(const mint a) const { return mint(*this) *= a;} mint pow(ll t) const { if (!t) return 1; mint a = pow(t>>1); a *= a; if (t&1) a *= *this; return a; } // for prime mod mint inv() const { return pow(mod-2);} mint& operator/=(const mint a) { return *this *= a.inv();} mint operator/(const mint a) const { return mint(*this) /= a;} }; istream& operator>>(istream& is, const mint& a) { return is >> a.x;} ostream& operator<<(ostream& os, const mint& a) { return os << a.x;} int main() { int n, q; cin >> n >> q; vector<int> a(n); rep(i,n) cin >> a[i]; sort(a.begin(), a.end(), greater<int>()); vector<mint> cum(n + 1, 0); cum[0] = 1; for (int i = 0; i < n; i++) cum[i + 1] = cum[i] * a[i]; vector<vector<mint>> dp(n + 1, vector<mint>(n + 1, 0)); dp[0][0] = 1; for (int i = 0; i < n; i++) { for (int j = 0; j <= n; j++) { dp[i + 1][j] += dp[i][j] * (a[i] - 1); if (j < n) dp[i + 1][j + 1] += dp[i][j]; } } reverse(a.begin(), a.end()); while (q--) { ll l, r, p; cin >> l >> r >> p; ll res = 0; for (ll x = l; x <= r; x++) { int itr = a.end() - lower_bound(a.begin(), a.end(), x); mint tmp = dp[itr][p] * cum[n] / cum[itr]; res ^= tmp.x; } cout << res % mod << endl; } return 0; }