結果
問題 | No.1067 #いろいろな色 / Red and Blue and more various colors (Middle) |
ユーザー | firiexp |
提出日時 | 2020-05-29 22:31:30 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 372 ms / 2,000 ms |
コード長 | 2,929 bytes |
コンパイル時間 | 1,417 ms |
コンパイル使用メモリ | 118,244 KB |
実行使用メモリ | 12,336 KB |
最終ジャッジ日時 | 2024-11-06 05:56:55 |
合計ジャッジ時間 | 5,367 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,816 KB |
testcase_01 | AC | 2 ms
6,820 KB |
testcase_02 | AC | 2 ms
6,816 KB |
testcase_03 | AC | 2 ms
6,820 KB |
testcase_04 | AC | 2 ms
6,816 KB |
testcase_05 | AC | 3 ms
6,820 KB |
testcase_06 | AC | 2 ms
6,820 KB |
testcase_07 | AC | 3 ms
6,816 KB |
testcase_08 | AC | 3 ms
6,820 KB |
testcase_09 | AC | 3 ms
6,816 KB |
testcase_10 | AC | 2 ms
6,816 KB |
testcase_11 | AC | 216 ms
8,448 KB |
testcase_12 | AC | 226 ms
8,960 KB |
testcase_13 | AC | 372 ms
6,816 KB |
testcase_14 | AC | 301 ms
6,820 KB |
testcase_15 | AC | 102 ms
6,816 KB |
testcase_16 | AC | 92 ms
8,308 KB |
testcase_17 | AC | 19 ms
6,816 KB |
testcase_18 | AC | 268 ms
6,816 KB |
testcase_19 | AC | 275 ms
6,820 KB |
testcase_20 | AC | 76 ms
8,572 KB |
testcase_21 | AC | 226 ms
12,060 KB |
testcase_22 | AC | 229 ms
12,336 KB |
testcase_23 | AC | 228 ms
12,116 KB |
testcase_24 | AC | 2 ms
6,820 KB |
testcase_25 | AC | 2 ms
6,820 KB |
ソースコード
#include <iostream> #include <algorithm> #include <map> #include <set> #include <queue> #include <stack> #include <numeric> #include <bitset> #include <cmath> static const int MOD = 998244353; using ll = long long; using u32 = unsigned; using u64 = unsigned long long; using namespace std; template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208; template<u32 M = 1000000007> struct modint{ u32 val; modint(): val(0){} template<typename T> modint(T t){t %= (T)M; if(t < 0) t += (T)M; val = t;} modint pow(ll k) const { modint res(1), x(val); while(k){ if(k&1) res *= x; x *= x; k >>= 1; } return res; } template<typename T> modint& operator=(T t){t %= (T)M; if(t < 0) t += (T)M; val = t; return *this;} modint inv() const {return pow(M-2);} modint& operator+=(modint a){val += a.val; if(val >= M) val -= M; return *this;} modint& operator-=(modint a){if(val < a.val) val += M-a.val; else val -= a.val; return *this;} modint& operator*=(modint a){val = (u64)val*a.val%M; return *this;} modint& operator/=(modint a){return (*this) *= a.inv();} modint operator+(modint a) const {return modint(val) +=a;} modint operator-(modint a) const {return modint(val) -=a;} modint operator*(modint a) const {return modint(val) *=a;} modint operator/(modint a) const {return modint(val) /=a;} modint operator-(){return modint(M-val);} bool operator==(const modint a) const {return val == a.val;} bool operator!=(const modint a) const {return val != a.val;} bool operator<(const modint a) const {return val < a.val;} }; using mint = modint<MOD>; int main() { int n, q; cin >> n >> q; vector<mint> dp(n+1); // reversed!!! dp[0] = 1; int cnt = 0; vector<int> v(n); for (int i = 0; i < n; ++i) { scanf("%d", &v[i]); for (int j = n-1; j >= 0; --j) { dp[j+1] += dp[j]*mint(v[i]-1); } cnt++; } sort(v.begin(),v.end()); vector<pair<int, int>> event; vector<int> ps(q); for (int i = 0; i < q; ++i) { int l, r; scanf("%d %d %d", &l, &r, &ps[i]); for (int j = l; j <= r; ++j) { event.emplace_back(j, i); } } set<int> s; sort(event.begin(),event.end()); int cur = 0; vector<int> ans(q); for (int i = 0; i < event.size(); ++i) { while(cur < v.size() && event[i].first > v[cur]){ for (int j = 0; j < n; ++j) { dp[j+1] -= dp[j]*(v[cur]-1); } for (int j = 0; j <= n; ++j) { dp[j] *= mint(v[cur]); } cnt--; cur++; } if(cnt >= ps[event[i].second]) ans[event[i].second] ^= dp[cnt-ps[event[i].second]].val; } for (int i = 0; i < q; ++i) { printf("%d\n", ans[i]); } return 0; }