Advertisement
tiom4eg

openol F 76/100

Jan 16th, 2023
717
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 4.00 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. // tiom4eg's precompiler options
  3. // POGGERS POGGERS POGGERS POGGERS POGGERS POGGERS POGGERS
  4. // IO settings
  5. #define fastIO ios_base::sync_with_stdio(false); cin.tie(0)
  6. // Quick types
  7. #define ll long long
  8. #define ld long double
  9. #define ull unsigned long long
  10. #define pii pair <int, int>
  11. #define vi vector <int>
  12. #define mi vector <vector <int>>
  13. // Quick functions
  14. #define endl "\n"
  15. #define F first
  16. #define S second
  17. #define all(a) a.begin(), a.end()
  18. #define sz(a) (int)(a.size())
  19. #define pb push_back
  20. #define mp make_pair
  21. // Quick fors
  22. #define FOR(i, a, b) for (int i = a; i < b; ++i)
  23. #define FORS(i, a, b, c) for (int i = a; i < b; i += c)
  24. #define RFOR(i, a, b) for (int i = a; i >= b; --i)
  25. #define EACH(e, a) for (auto& e : a)
  26. // Pragmas
  27. #ifndef TIOM4EG
  28. #pragma GCC optimize("O3,unroll-loops") // let the chaos begin!
  29. #pragma GCC target("avx,avx2,bmi,bmi2,popcnt,lzcnt,tune=native")
  30. #pragma GCC comment(linker, "/stack:200000000")
  31. #endif
  32. // PBDS
  33. #include <ext/pb_ds/assoc_container.hpp>
  34. #include <ext/pb_ds/tree_policy.hpp>
  35. #define ordered_set tree <int, null_type, less <int>, rb_tree_tag, tree_order_statistics_node_update>
  36. #define ook order_of_key
  37. #define fbo find_by_order
  38. using namespace __gnu_pbds;
  39. // POGGERS POGGERS POGGERS POGGERS POGGERS POGGERS POGGERS
  40. using namespace std;
  41. mt19937 rng(chrono::duration_cast<chrono::milliseconds>(chrono::system_clock::now().time_since_epoch()).count());
  42. //#define int long long
  43. 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;
  44. 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};
  45.  
  46. #define mat array <array <int, 2>, 2>
  47. 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}}}};
  48. const mat eye = {{{1, 0}, {0, 1}}};
  49.  
  50. mat mul(mat& a, mat& b) {
  51.     mat c{};
  52.     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;
  53.     return c;
  54. }
  55.  
  56. mat t[2 * R];
  57.  
  58. void upd(int p, int x) {
  59.     t[p += R] = xd[x];
  60.     while (p > 1) p >>= 1, t[p] = mul(t[2 * p], t[2 * p + 1]);
  61. }
  62.  
  63. mat get(int l, int r) {
  64.     l += R, r += R;
  65.     mat lp = eye, rp = eye;
  66.     while (l < r) {
  67.         if (l & 1) lp = mul(lp, t[l]);
  68.         if (!(r & 1)) rp = mul(t[r], rp);
  69.         l = (l + 1) >> 1, r = (r - 1) >> 1;
  70.     }
  71.     if (l == r) lp = mul(lp, t[l]);
  72.     return mul(lp, rp);
  73. }
  74.  
  75. signed main() {
  76.     fastIO;
  77.     int n; cin >> n;
  78.     FOR(i, 0, n) {
  79.         char c; cin >> c;
  80.         t[R + i] = xd[lookup[c] + 4];
  81.     }
  82.     RFOR(i, R - 1, 1) t[i] = mul(t[2 * i], t[2 * i + 1]);
  83.     int q; cin >> q;
  84.     while (q--) {
  85.         int op; cin >> op;
  86.         if (op == 1) {
  87.             int p; char c; cin >> p >> c, --p;
  88.             upd(p, lookup[c] + 4);
  89.         } else {
  90.             int l, r; cin >> l >> r, --l, --r;
  91.             cout << (eye == get(l, r) ? "Yes" : "No") << endl;
  92.         }
  93.     }
  94. }
  95.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement