Submission #831231

# Submission time Handle Problem Language Result Execution time Memory
831231 2023-08-20T01:14:13 Z perchuts Crossing (JOI21_crossing) C++17
26 / 100
415 ms 36048 KB
#include <bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define sz(x) (int) x.size()
#define endl '\n'
#define pb push_back
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int ll

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ii = pair<int,int>;
using iii = tuple<int,int,int>;

const int inf = 2e9+1;
const int mod = 1e9+7;
const int maxn = 3e5+100;

template<typename X, typename Y> bool ckmin(X& x, const Y& y) { return (y < x) ? (x=y,1):0; }
template<typename X, typename Y> bool ckmax(X& x, const Y& y) { return (x < y) ? (x=y,1):0; }

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int rnd(int l, int r) {
      uniform_int_distribution<ll> uid(l, r);
      return uid(rng);
}

int pr[maxn][3], seg[4*maxn], lz[4*maxn];

void push(int i, int l, int r) {
      if (lz[i] == 3) return;
      seg[i] = pr[r][lz[i]] ^ pr[l-1][lz[i]];
      if (l != r) lz[2*i] = lz[2*i+1] = lz[i];
      lz[i] = 3;
}

void upd(int i, int l, int r, int x, int y, int k) {
      push(i, l, r);
      if (r < x || y < l) return;
      if (x <= l && r <= y) {
            lz[i] = k;
            push(i, l, r);
            return;
      }
      int md = (l + r) / 2;
      upd(2*i, l, md, x, y, k), upd(2*i+1, md+1, r, x, y, k);
      seg[i] = seg[2*i] ^ seg[2*i+1];
}

int32_t main(){_
      int n; cin >> n; string a, b, c; cin >> a >> b >> c;
      // there are only 27 strings that can be generated (trust)
      map<char, int> f;

      f['J'] = 2, f['O'] = 0, f['I'] = 1;

      for (int i = 0; i < 3; ++i) {
            for (int j = 1; j <= n; ++j) {
                  pr[j][i] = pr[j-1][i] ^ rnd(0, 8e18);
            }
      }

      map<int, bool> existe;

      for (int i = 0; i < 3; ++i) {
            for (int j = 0; j < 3; ++j) {
                  for (int k = 0; k < 3; ++k) {
                        int x = 0;
                        if (i + j + k == 0) continue;
                        for (int w = 1; w <= n; ++w) {
                              int ac = f[a[w-1]], bc = f[b[w-1]], cc = f[c[w-1]];
                              int res = (ac * i + bc * j + cc * k) % 3;
                              if (ac == bc && bc == cc) res = ac;
                              x ^= pr[w][res] ^ pr[w-1][res];
                        }
                        existe[x] = 1;
                  }
            }
      }

      for (int i = 1; i < 4*maxn; ++i) lz[i] = 3;

      int q; cin >> q;
      string t; cin >> t;

      for (int i = 1; i <= n; ++i) upd(1, 1, n, i, i, f[t[i-1]]);

      cout << (existe[seg[1]] == 1 ? "Yes" : "No") << endl;

      while (q--) {
            int l, r; char c; cin >> l >> r >> c;
            upd(1, 1, n, l, r, f[c]);
            cout << (existe[seg[1]] == 1 ? "Yes" : "No") << endl;
      }
}
# Verdict Execution time Memory Grader output
1 Correct 108 ms 19656 KB Output is correct
2 Correct 125 ms 21984 KB Output is correct
3 Correct 100 ms 15412 KB Output is correct
4 Correct 117 ms 21832 KB Output is correct
5 Correct 113 ms 21956 KB Output is correct
6 Correct 112 ms 21148 KB Output is correct
7 Correct 125 ms 21504 KB Output is correct
8 Correct 118 ms 22252 KB Output is correct
9 Correct 128 ms 21896 KB Output is correct
10 Correct 125 ms 23324 KB Output is correct
11 Correct 130 ms 22808 KB Output is correct
12 Correct 134 ms 23348 KB Output is correct
13 Correct 138 ms 22668 KB Output is correct
14 Correct 138 ms 23400 KB Output is correct
15 Correct 125 ms 22660 KB Output is correct
16 Correct 132 ms 23372 KB Output is correct
17 Correct 125 ms 22592 KB Output is correct
18 Correct 78 ms 13664 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 108 ms 19656 KB Output is correct
2 Correct 125 ms 21984 KB Output is correct
3 Correct 100 ms 15412 KB Output is correct
4 Correct 117 ms 21832 KB Output is correct
5 Correct 113 ms 21956 KB Output is correct
6 Correct 112 ms 21148 KB Output is correct
7 Correct 125 ms 21504 KB Output is correct
8 Correct 118 ms 22252 KB Output is correct
9 Correct 128 ms 21896 KB Output is correct
10 Correct 125 ms 23324 KB Output is correct
11 Correct 130 ms 22808 KB Output is correct
12 Correct 134 ms 23348 KB Output is correct
13 Correct 138 ms 22668 KB Output is correct
14 Correct 138 ms 23400 KB Output is correct
15 Correct 125 ms 22660 KB Output is correct
16 Correct 132 ms 23372 KB Output is correct
17 Correct 125 ms 22592 KB Output is correct
18 Correct 78 ms 13664 KB Output is correct
19 Correct 415 ms 33352 KB Output is correct
20 Correct 361 ms 33948 KB Output is correct
21 Correct 363 ms 34392 KB Output is correct
22 Correct 310 ms 31644 KB Output is correct
23 Correct 169 ms 25652 KB Output is correct
24 Correct 165 ms 24384 KB Output is correct
25 Correct 370 ms 35600 KB Output is correct
26 Correct 350 ms 33700 KB Output is correct
27 Correct 374 ms 36048 KB Output is correct
28 Correct 331 ms 33700 KB Output is correct
29 Correct 326 ms 35540 KB Output is correct
30 Correct 216 ms 25560 KB Output is correct
31 Correct 359 ms 36024 KB Output is correct
32 Correct 325 ms 32800 KB Output is correct
33 Correct 170 ms 24324 KB Output is correct
34 Correct 351 ms 33680 KB Output is correct
35 Correct 303 ms 32072 KB Output is correct
36 Correct 163 ms 24416 KB Output is correct
37 Correct 166 ms 24416 KB Output is correct
38 Correct 278 ms 31196 KB Output is correct
39 Correct 257 ms 29988 KB Output is correct
40 Correct 265 ms 29832 KB Output is correct
41 Correct 319 ms 23836 KB Output is correct
42 Correct 134 ms 23204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 108 ms 19656 KB Output is correct
2 Correct 125 ms 21984 KB Output is correct
3 Correct 100 ms 15412 KB Output is correct
4 Correct 117 ms 21832 KB Output is correct
5 Correct 113 ms 21956 KB Output is correct
6 Correct 112 ms 21148 KB Output is correct
7 Correct 125 ms 21504 KB Output is correct
8 Correct 118 ms 22252 KB Output is correct
9 Correct 128 ms 21896 KB Output is correct
10 Correct 125 ms 23324 KB Output is correct
11 Correct 130 ms 22808 KB Output is correct
12 Correct 134 ms 23348 KB Output is correct
13 Correct 138 ms 22668 KB Output is correct
14 Correct 138 ms 23400 KB Output is correct
15 Correct 125 ms 22660 KB Output is correct
16 Correct 132 ms 23372 KB Output is correct
17 Correct 125 ms 22592 KB Output is correct
18 Correct 78 ms 13664 KB Output is correct
19 Correct 114 ms 21456 KB Output is correct
20 Correct 96 ms 15420 KB Output is correct
21 Correct 125 ms 22820 KB Output is correct
22 Correct 112 ms 20692 KB Output is correct
23 Correct 126 ms 22860 KB Output is correct
24 Correct 121 ms 21712 KB Output is correct
25 Correct 129 ms 22768 KB Output is correct
26 Correct 123 ms 21456 KB Output is correct
27 Correct 136 ms 22732 KB Output is correct
28 Correct 109 ms 21592 KB Output is correct
29 Correct 118 ms 22188 KB Output is correct
30 Correct 120 ms 21004 KB Output is correct
31 Correct 139 ms 23048 KB Output is correct
32 Correct 117 ms 22860 KB Output is correct
33 Correct 121 ms 22348 KB Output is correct
34 Correct 129 ms 21372 KB Output is correct
35 Correct 133 ms 23408 KB Output is correct
36 Correct 123 ms 22608 KB Output is correct
37 Correct 135 ms 23404 KB Output is correct
38 Correct 129 ms 22612 KB Output is correct
39 Correct 129 ms 23372 KB Output is correct
40 Correct 126 ms 22568 KB Output is correct
41 Correct 134 ms 23408 KB Output is correct
42 Correct 154 ms 22788 KB Output is correct
43 Incorrect 124 ms 21924 KB Output isn't correct
44 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 108 ms 19656 KB Output is correct
2 Correct 125 ms 21984 KB Output is correct
3 Correct 100 ms 15412 KB Output is correct
4 Correct 117 ms 21832 KB Output is correct
5 Correct 113 ms 21956 KB Output is correct
6 Correct 112 ms 21148 KB Output is correct
7 Correct 125 ms 21504 KB Output is correct
8 Correct 118 ms 22252 KB Output is correct
9 Correct 128 ms 21896 KB Output is correct
10 Correct 125 ms 23324 KB Output is correct
11 Correct 130 ms 22808 KB Output is correct
12 Correct 134 ms 23348 KB Output is correct
13 Correct 138 ms 22668 KB Output is correct
14 Correct 138 ms 23400 KB Output is correct
15 Correct 125 ms 22660 KB Output is correct
16 Correct 132 ms 23372 KB Output is correct
17 Correct 125 ms 22592 KB Output is correct
18 Correct 78 ms 13664 KB Output is correct
19 Correct 415 ms 33352 KB Output is correct
20 Correct 361 ms 33948 KB Output is correct
21 Correct 363 ms 34392 KB Output is correct
22 Correct 310 ms 31644 KB Output is correct
23 Correct 169 ms 25652 KB Output is correct
24 Correct 165 ms 24384 KB Output is correct
25 Correct 370 ms 35600 KB Output is correct
26 Correct 350 ms 33700 KB Output is correct
27 Correct 374 ms 36048 KB Output is correct
28 Correct 331 ms 33700 KB Output is correct
29 Correct 326 ms 35540 KB Output is correct
30 Correct 216 ms 25560 KB Output is correct
31 Correct 359 ms 36024 KB Output is correct
32 Correct 325 ms 32800 KB Output is correct
33 Correct 170 ms 24324 KB Output is correct
34 Correct 351 ms 33680 KB Output is correct
35 Correct 303 ms 32072 KB Output is correct
36 Correct 163 ms 24416 KB Output is correct
37 Correct 166 ms 24416 KB Output is correct
38 Correct 278 ms 31196 KB Output is correct
39 Correct 257 ms 29988 KB Output is correct
40 Correct 265 ms 29832 KB Output is correct
41 Correct 319 ms 23836 KB Output is correct
42 Correct 134 ms 23204 KB Output is correct
43 Correct 114 ms 21456 KB Output is correct
44 Correct 96 ms 15420 KB Output is correct
45 Correct 125 ms 22820 KB Output is correct
46 Correct 112 ms 20692 KB Output is correct
47 Correct 126 ms 22860 KB Output is correct
48 Correct 121 ms 21712 KB Output is correct
49 Correct 129 ms 22768 KB Output is correct
50 Correct 123 ms 21456 KB Output is correct
51 Correct 136 ms 22732 KB Output is correct
52 Correct 109 ms 21592 KB Output is correct
53 Correct 118 ms 22188 KB Output is correct
54 Correct 120 ms 21004 KB Output is correct
55 Correct 139 ms 23048 KB Output is correct
56 Correct 117 ms 22860 KB Output is correct
57 Correct 121 ms 22348 KB Output is correct
58 Correct 129 ms 21372 KB Output is correct
59 Correct 133 ms 23408 KB Output is correct
60 Correct 123 ms 22608 KB Output is correct
61 Correct 135 ms 23404 KB Output is correct
62 Correct 129 ms 22612 KB Output is correct
63 Correct 129 ms 23372 KB Output is correct
64 Correct 126 ms 22568 KB Output is correct
65 Correct 134 ms 23408 KB Output is correct
66 Correct 154 ms 22788 KB Output is correct
67 Incorrect 124 ms 21924 KB Output isn't correct
68 Halted 0 ms 0 KB -