Submission #684057

#TimeUsernameProblemLanguageResultExecution timeMemory
684057piOOECrossing (JOI21_crossing)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>   using namespace std; using ll = long long;   string cross(string &a, string &b) { string res(a.size(), 'a'); for (int i = 0; i < a.size(); ++i) { if (a[i] == b[i]) { res[i] = a[i]; } else { res[i] = 'J' ^ 'O' ^ 'I' ^ a[i] ^ b[i]; } } return res; }   constexpr int MOD = 1e9 + 9; constexpr int P = 239;   struct Info { int h, power, sum;   Info() = default; Info(int a, int b) : h(a), power(b) {} };   vector<Info> t; vector<int> tag; int sz;   void apply(int x, int y) { if (y != -1) { t[x].h = 1LL * t[x].sum * y % MOD; tag[x] = y; } }   void push(int x) { apply(x << 1, tag[x]); apply(x << 1 | 1, tag[x]); tag[x] = -1; }   void pull(int x) { t[x].h = (t[x << 1].h + 1LL * t[x << 1].power * P % MOD * t[x << 1 | 1].h) % MOD; t[x].power = 1LL * t[x << 1].power * t[x << 1 | 1].power % MOD * P % MOD; t[x].sum = (t[x << 1].sum + 1LL * t[x << 1].power * P % MOD * t[x << 1 | 1].sum) % MOD; }   int to_int(char c) { return c == 'J' ? 0 : 1 + (c != 'O'); }   void init(int n, string T) { sz = 1 << __lg(n) + bool(n & (n - 1)); tag.assign(sz << 1, -1), t.resize(sz << 1);   for (int i = 0; i < n; ++i) { t[i + sz].sum = t[i + sz].power = 1; t[i + sz].h = to_int(T[i]); } for (int i = sz - 1; i > 0; --i) { pull(i); } }   void rangeApply(int l, int r, int tg, int x = 1, int lx = 0, int rx = sz) { if (l >= rx || lx >= r) { return; } if (l <= lx && rx <= r) { apply(x, tg); return; }   push(x);   int mid = (lx + rx) >> 1;   rangeApply(l, r, tg, x << 1, lx, mid), rangeApply(l, r, tg, x << 1 | 1, mid, rx);   pull(x); }   int hashed(string &s) { int ans = 0; for (int i = int(s.size()) - 1; i >= 0; --i) { ans = (1LL * ans * P + to_int(s[i])) % MOD; } return ans; }   int main() { ios::sync_with_stdio(false); cin.tie(nullptr);   int n; cin >> n;   string A, B, C; cin >> A >> B >> C;   unordered_set<string> every{A, B, C};   queue<string> qu; qu.push(A), qu.push(B), qu.push(C);   while (!qu.empty()) { string s = qu.front(); qu.pop();   for (string to : every) { string res = cross(s, to);   if (!every.count(res)) { qu.push(res); every.insert(res); } } }   unordered_set<int> st; for (string s : every) { st.insert(hashed(s)); }   int q; cin >> q;   string T; cin >> T;   init(n, T);   cout << (st.count(t[1].h) ? "Yes\n" : "No\n");   while (q--) { int l, r; char c; cin >> l >> r >> c;   rangeApply(l - 1, r, to_int(c));   cout << (st.count(t[1].h) ? "Yes\n" : "No\n"); }   return 0; }

Compilation message (stderr)

Main.cpp:2:1: error: extended character   is not valid in an identifier
    2 |  
      | ^
Main.cpp:5:1: error: extended character   is not valid in an identifier
    5 |  
      | ^
Main.cpp:17:1: error: extended character   is not valid in an identifier
   17 |  
      | ^
Main.cpp:20:1: error: extended character   is not valid in an identifier
   20 |  
      | ^
Main.cpp:23:1: error: extended character   is not valid in an identifier
   23 |  
      | ^
Main.cpp:27:1: error: extended character   is not valid in an identifier
   27 |  
      | ^
Main.cpp:31:1: error: extended character   is not valid in an identifier
   31 |  
      | ^
Main.cpp:38:1: error: extended character   is not valid in an identifier
   38 |  
      | ^
Main.cpp:44:1: error: extended character   is not valid in an identifier
   44 |  
      | ^
Main.cpp:50:1: error: extended character   is not valid in an identifier
   50 |  
      | ^
Main.cpp:54:1: error: extended character   is not valid in an identifier
   54 |  
      | ^
Main.cpp:58:1: error: extended character   is not valid in an identifier
   58 |  
      | ^
Main.cpp:67:1: error: extended character   is not valid in an identifier
   67 |  
      | ^
Main.cpp:76:1: error: extended character   is not valid in an identifier
   76 |  
      | ^
Main.cpp:78:1: error: extended character   is not valid in an identifier
   78 |  
      | ^
Main.cpp:80:1: error: extended character   is not valid in an identifier
   80 |  
      | ^
Main.cpp:82:1: error: extended character   is not valid in an identifier
   82 |  
      | ^
Main.cpp:85:1: error: extended character   is not valid in an identifier
   85 |  
      | ^
Main.cpp:93:1: error: extended character   is not valid in an identifier
   93 |  
      | ^
Main.cpp:97:1: error: extended character   is not valid in an identifier
   97 |  
      | ^
Main.cpp:100:1: error: extended character   is not valid in an identifier
  100 |  
      | ^
Main.cpp:103:1: error: extended character   is not valid in an identifier
  103 |  
      | ^
Main.cpp:105:1: error: extended character   is not valid in an identifier
  105 |  
      | ^
Main.cpp:108:1: error: extended character   is not valid in an identifier
  108 |  
      | ^
Main.cpp:112:1: error: extended character   is not valid in an identifier
  112 |  
      | ^
Main.cpp:115:1: error: extended character   is not valid in an identifier
  115 |  
      | ^
Main.cpp:122:1: error: extended character   is not valid in an identifier
  122 |  
      | ^
Main.cpp:127:1: error: extended character   is not valid in an identifier
  127 |  
      | ^
Main.cpp:130:1: error: extended character   is not valid in an identifier
  130 |  
      | ^
Main.cpp:133:1: error: extended character   is not valid in an identifier
  133 |  
      | ^
Main.cpp:135:1: error: extended character   is not valid in an identifier
  135 |  
      | ^
Main.cpp:137:1: error: extended character   is not valid in an identifier
  137 |  
      | ^
Main.cpp:142:1: error: extended character   is not valid in an identifier
  142 |  
      | ^
Main.cpp:144:1: error: extended character   is not valid in an identifier
  144 |  
      | ^
Main.cpp:147:1: error: extended character   is not valid in an identifier
  147 |  
      | ^
Main.cpp:2:1: error: '\U000000a0' does not name a type
    2 |  
      | ^
Main.cpp:5:1: error: '\U000000a0' does not name a type
    5 |  
      | ^
Main.cpp:17:1: error: '\U000000a0' does not name a type
   17 |  
      | ^
Main.cpp:20:1: error: '\U000000a0' does not name a type
   20 |  
      | ^
Main.cpp:27:1: error: '\U000000a0' does not name a type
   27 |  
      | ^
Main.cpp:29:1: error: 'vector' does not name a type
   29 | vector<int> tag;
      | ^~~~~~
Main.cpp:31:1: error: '\U000000a0' does not name a type
   31 |  
      | ^
Main.cpp:38:1: error: '\U000000a0' does not name a type
   38 |  
      | ^
Main.cpp:44:1: error: '\U000000a0' does not name a type
   44 |  
      | ^
Main.cpp:50:1: error: '\U000000a0' does not name a type
   50 |  
      | ^
Main.cpp:54:1: error: '\U000000a0' does not name a type
   54 |  
      | ^
Main.cpp:67:1: error: '\U000000a0' does not name a type
   67 |  
      | ^
Main.cpp:85:1: error: '\U000000a0' does not name a type
   85 |  
      | ^
Main.cpp:93:1: error: '\U000000a0' does not name a type
   93 |  
      | ^