Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- // tiom4eg's precompiler options
- // POGGERS POGGERS POGGERS POGGERS POGGERS POGGERS POGGERS
- // IO settings
- #define fastIO ios_base::sync_with_stdio(false); cin.tie(0)
- // Quick types
- #define ll long long
- #define ld long double
- #define ull unsigned long long
- #define pii pair <int, int>
- #define vi vector <int>
- #define mi vector <vector <int>>
- // Quick functions
- #define endl "\n"
- #define F first
- #define S second
- #define all(a) a.begin(), a.end()
- #define sz(a) (int)(a.size())
- #define pb push_back
- #define mp make_pair
- // Quick fors
- #define FOR(i, a, b) for (int i = a; i < b; ++i)
- #define FORS(i, a, b, c) for (int i = a; i < b; i += c)
- #define RFOR(i, a, b) for (int i = a; i >= b; --i)
- #define EACH(e, a) for (auto& e : a)
- // Pragmas
- #ifndef TIOM4EG
- #pragma GCC optimize("O3,unroll-loops") // let the chaos begin!
- #pragma GCC target("avx,avx2,bmi,bmi2,popcnt,lzcnt,tune=native")
- #pragma GCC comment(linker, "/stack:200000000")
- #endif
- // PBDS
- #include <ext/pb_ds/assoc_container.hpp>
- #include <ext/pb_ds/tree_policy.hpp>
- #define ordered_set tree <int, null_type, less <int>, rb_tree_tag, tree_order_statistics_node_update>
- #define ook order_of_key
- #define fbo find_by_order
- using namespace __gnu_pbds;
- // POGGERS POGGERS POGGERS POGGERS POGGERS POGGERS POGGERS
- using namespace std;
- mt19937 rng(chrono::duration_cast<chrono::milliseconds>(chrono::system_clock::now().time_since_epoch()).count());
- //#define int long long
- const int INF = 1e9 + 7, INFLL = 1e13 + 7, MD = 998244353, MAX = 200007, MOD = 1040015701, LG = 30, B = 31, INV = 129032259, S = 10008, R = 1 << 18;
- const int lookup[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, -4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, -2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, -3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
- #define mat array <array <int, 2>, 2>
- const mat xd[9] = {{{{421181217, 681263521}, {695652834, 142890536}}}, {{{552125364, 298788583}, {572580134, 245593401}}}, {{{1000394207, 576708089}, {612650076, 71792560}}}, {{{456086816, 389376970}, {639496946, 652050922}}}, {{{0, 0}, {0, 0}}}, {{{678263274, 226248974}, {57393340, 900817905}}}, {{{794627273, 515146282}, {77090928, 502957571}}}, {{{5859975, 480316801}, {244694603, 627884321}}}, {{{892782953, 1018029598}, {806477031, 48175585}}}};
- const mat eye = {{{1, 0}, {0, 1}}};
- mat mul(mat& a, mat& b) {
- mat c{};
- FOR(i, 0, 2) FOR(j, 0, 2) FOR(k, 0, 2) c[i][j] = (a[i][k] * 1LL * b[k][j] + c[i][j]) % MOD;
- return c;
- }
- mat t[2 * R];
- void upd(int p, int x) {
- t[p += R] = xd[x];
- while (p > 1) p >>= 1, t[p] = mul(t[2 * p], t[2 * p + 1]);
- }
- mat get(int l, int r) {
- l += R, r += R;
- mat lp = eye, rp = eye;
- while (l < r) {
- if (l & 1) lp = mul(lp, t[l]);
- if (!(r & 1)) rp = mul(t[r], rp);
- l = (l + 1) >> 1, r = (r - 1) >> 1;
- }
- if (l == r) lp = mul(lp, t[l]);
- return mul(lp, rp);
- }
- signed main() {
- fastIO;
- int n; cin >> n;
- FOR(i, 0, n) {
- char c; cin >> c;
- t[R + i] = xd[lookup[c] + 4];
- }
- RFOR(i, R - 1, 1) t[i] = mul(t[2 * i], t[2 * i + 1]);
- int q; cin >> q;
- while (q--) {
- int op; cin >> op;
- if (op == 1) {
- int p; char c; cin >> p >> c, --p;
- upd(p, lookup[c] + 4);
- } else {
- int l, r; cin >> l >> r, --l, --r;
- cout << (eye == get(l, r) ? "Yes" : "No") << endl;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement