結果
問題 | No.1067 #いろいろな色 / Red and Blue and more various colors (Middle) |
ユーザー | firiexp |
提出日時 | 2020-05-29 22:31:09 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,930 bytes |
コンパイル時間 | 1,453 ms |
コンパイル使用メモリ | 117,236 KB |
実行使用メモリ | 12,860 KB |
最終ジャッジ日時 | 2024-11-06 05:54:50 |
合計ジャッジ時間 | 4,893 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,816 KB |
testcase_01 | AC | 2 ms
6,816 KB |
testcase_02 | WA | - |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | AC | 2 ms
6,820 KB |
testcase_08 | WA | - |
testcase_09 | AC | 2 ms
6,820 KB |
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 | WA | - |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | AC | 2 ms
6,816 KB |
testcase_25 | AC | 2 ms
6,816 KB |
ソースコード
#include <iostream> #include <algorithm> #include <map> #include <set> #include <queue> #include <stack> #include <numeric> #include <bitset> #include <cmath> static const int MOD = 1000000007; 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; }