Submission #864202

# Submission time Handle Problem Language Result Execution time Memory
864202 2023-10-22T08:41:10 Z vjudge1 Crossing (JOI21_crossing) C++17
100 / 100
1440 ms 97552 KB
/* DK ORZ! */
#include "iostream"
#include "cstdio"
#include "cstdlib"
#include "algorithm"
#include "cmath"
#include "vector"
#include "set"
#include "map"
#include "unordered_set"
#include "unordered_map"
#include "queue"
#include "ctime"
#include "random"
#include "cassert"
#include "complex"
#include "string"
#include "cstring"
#include "chrono"
#include "bitset"
#include "array"
#include "stack"

#define endl '\n'
#define all(x) x.begin(), x.end()
#define int long long

using namespace std;

const int mod = 998244353;
const int nax = 200000;

string T, s[3];
int n, q;
vector <string> niza;

// Kombiniraj dva stringa
string Get_String(string a, string b){
  string res = "";
  for (int i = 0; i < n; i++){
    if (a[i] != b[i]){
      if (a[i] != 'J' && b[i] != 'J')
        res += 'J';
      else if (a[i] != 'I' && b[i] != 'I')
        res += 'I';
      else
        res += 'O';
    }else
      res += a[i];
  }
  return res;
}


struct Segment_Tree{
  pair <int,char> t[nax * 3];
  char Lazy[nax * 3];
  int index = 0;

  void push(int k, int l, int r){
    if (l == r || Lazy[k] == 'z')return;
    t[k].first = (t[k].second == Lazy[k]);
    Lazy[k * 2] = Lazy[k];
    Lazy[k * 2 + 1] = Lazy[k];
    t[k * 2].first = t[k * 2].second == Lazy[k];
    t[k * 2+1].first = t[k * 2+1].second == Lazy[k];
    Lazy[k] = 'z';
  }

  void build(int l = 0, int r = n - 1, int k = 1){
    t[k].first = 0;
    t[k].second = 'z'; //debilna vrednost
    Lazy[k] = 'z';
    if (l == r){
      t[k].first = (T[l] == niza[index][l]);
      t[k].second = (niza[index][l]);
      return;
    }

    int mid = (l+r) / 2;
    build(l,mid,k*2);
    build(mid+1,r,k*2+1);

    t[k].first = (t[k * 2].first & t[k * 2 + 1].first);
    if (t[k * 2].second == t[k * 2 + 1].second)
      t[k].second = t[k * 2].second;
  }

  void update(int ll, int rr, char nova, int l = 0, int r = n - 1, int k = 1){
    push(k, l, r);
    if (l >= ll && r <= rr){
      t[k].first = (t[k].second == nova);
      Lazy[k] = nova;
      return;
    }
    if (l > rr || r < ll)return;

    int mid = (l+r) / 2;
    update(ll,rr,nova,l,mid,k*2);
    update(ll,rr,nova,mid+1,r,k*2+1);

    t[k].first = (t[k * 2].first & t[k * 2 + 1].first);
  }
};

vector <Segment_Tree> Site(9);

void solve(){
  cin >> n;
  cin >> s[0] >> s[1] >> s[2];
  for (int i = 0; i < 3; i++){
    for (int j = i; j < 3; j++){
      if (i == j)continue;
      int Third;
      if (i != 0 && j != 0)Third = 0;
      else if (i != 1 && j != 1)Third = 1;
      else Third = 2;
      niza.push_back(Get_String(s[i], s[j]));
      niza.push_back(Get_String(niza.back(), s[Third]));
    }
    niza.push_back(s[i]);
  }
  cin >> q;
  cin >> T;
  for (int i = 0; i < 9; i++){
    Site[i].index = i;
    Site[i].build();
  }

  int ok = 0;
  for (int i = 0; i < 9; i++){
    ok |= Site[i].t[1].first;
  }
  cout << (ok ? "Yes" : "No") << endl;
  while(q--){
    int l, r; 
    char v;
    cin >> l >> r >> v;
    --l,--r;
    ok = 0;
    for (int i = 0; i < 9; i++){
      Site[i].update(l,r,v);
      ok |= Site[i].t[1].first;
    }
    cout << (ok ? "Yes" : "No") << endl;
  }
}

signed main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  int tt = 1;
  //cin >> tt;
  while (tt--){
    solve();
  }
  return 0;
}

# Verdict Execution time Memory Grader output
1 Correct 159 ms 92240 KB Output is correct
2 Correct 178 ms 92368 KB Output is correct
3 Correct 169 ms 92252 KB Output is correct
4 Correct 140 ms 92100 KB Output is correct
5 Correct 143 ms 92200 KB Output is correct
6 Correct 150 ms 92064 KB Output is correct
7 Correct 140 ms 92176 KB Output is correct
8 Correct 150 ms 92364 KB Output is correct
9 Correct 158 ms 92392 KB Output is correct
10 Correct 154 ms 92424 KB Output is correct
11 Correct 162 ms 92392 KB Output is correct
12 Correct 153 ms 92208 KB Output is correct
13 Correct 155 ms 92160 KB Output is correct
14 Correct 152 ms 92244 KB Output is correct
15 Correct 156 ms 92240 KB Output is correct
16 Correct 151 ms 92264 KB Output is correct
17 Correct 154 ms 92284 KB Output is correct
18 Correct 158 ms 92264 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 159 ms 92240 KB Output is correct
2 Correct 178 ms 92368 KB Output is correct
3 Correct 169 ms 92252 KB Output is correct
4 Correct 140 ms 92100 KB Output is correct
5 Correct 143 ms 92200 KB Output is correct
6 Correct 150 ms 92064 KB Output is correct
7 Correct 140 ms 92176 KB Output is correct
8 Correct 150 ms 92364 KB Output is correct
9 Correct 158 ms 92392 KB Output is correct
10 Correct 154 ms 92424 KB Output is correct
11 Correct 162 ms 92392 KB Output is correct
12 Correct 153 ms 92208 KB Output is correct
13 Correct 155 ms 92160 KB Output is correct
14 Correct 152 ms 92244 KB Output is correct
15 Correct 156 ms 92240 KB Output is correct
16 Correct 151 ms 92264 KB Output is correct
17 Correct 154 ms 92284 KB Output is correct
18 Correct 158 ms 92264 KB Output is correct
19 Correct 1229 ms 97276 KB Output is correct
20 Correct 890 ms 97312 KB Output is correct
21 Correct 707 ms 97112 KB Output is correct
22 Correct 711 ms 96460 KB Output is correct
23 Correct 282 ms 93188 KB Output is correct
24 Correct 361 ms 93264 KB Output is correct
25 Correct 740 ms 97280 KB Output is correct
26 Correct 778 ms 97552 KB Output is correct
27 Correct 942 ms 97220 KB Output is correct
28 Correct 966 ms 97352 KB Output is correct
29 Correct 918 ms 97168 KB Output is correct
30 Correct 333 ms 93632 KB Output is correct
31 Correct 863 ms 97544 KB Output is correct
32 Correct 887 ms 97116 KB Output is correct
33 Correct 300 ms 93520 KB Output is correct
34 Correct 947 ms 97120 KB Output is correct
35 Correct 634 ms 96284 KB Output is correct
36 Correct 303 ms 93320 KB Output is correct
37 Correct 282 ms 93252 KB Output is correct
38 Correct 723 ms 97408 KB Output is correct
39 Correct 299 ms 97196 KB Output is correct
40 Correct 648 ms 96232 KB Output is correct
41 Correct 1440 ms 97324 KB Output is correct
42 Correct 65 ms 96828 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 159 ms 92240 KB Output is correct
2 Correct 178 ms 92368 KB Output is correct
3 Correct 169 ms 92252 KB Output is correct
4 Correct 140 ms 92100 KB Output is correct
5 Correct 143 ms 92200 KB Output is correct
6 Correct 150 ms 92064 KB Output is correct
7 Correct 140 ms 92176 KB Output is correct
8 Correct 150 ms 92364 KB Output is correct
9 Correct 158 ms 92392 KB Output is correct
10 Correct 154 ms 92424 KB Output is correct
11 Correct 162 ms 92392 KB Output is correct
12 Correct 153 ms 92208 KB Output is correct
13 Correct 155 ms 92160 KB Output is correct
14 Correct 152 ms 92244 KB Output is correct
15 Correct 156 ms 92240 KB Output is correct
16 Correct 151 ms 92264 KB Output is correct
17 Correct 154 ms 92284 KB Output is correct
18 Correct 158 ms 92264 KB Output is correct
19 Correct 174 ms 90828 KB Output is correct
20 Correct 198 ms 90704 KB Output is correct
21 Correct 149 ms 90760 KB Output is correct
22 Correct 127 ms 90704 KB Output is correct
23 Correct 149 ms 90708 KB Output is correct
24 Correct 150 ms 90796 KB Output is correct
25 Correct 153 ms 90724 KB Output is correct
26 Correct 144 ms 90708 KB Output is correct
27 Correct 150 ms 90704 KB Output is correct
28 Correct 149 ms 90648 KB Output is correct
29 Correct 159 ms 91104 KB Output is correct
30 Correct 127 ms 90708 KB Output is correct
31 Correct 151 ms 90840 KB Output is correct
32 Correct 151 ms 90840 KB Output is correct
33 Correct 156 ms 90808 KB Output is correct
34 Correct 147 ms 90788 KB Output is correct
35 Correct 151 ms 90704 KB Output is correct
36 Correct 160 ms 90660 KB Output is correct
37 Correct 179 ms 90640 KB Output is correct
38 Correct 154 ms 90728 KB Output is correct
39 Correct 150 ms 90712 KB Output is correct
40 Correct 166 ms 90708 KB Output is correct
41 Correct 151 ms 90860 KB Output is correct
42 Correct 155 ms 90708 KB Output is correct
43 Correct 143 ms 90708 KB Output is correct
44 Correct 153 ms 90632 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 159 ms 92240 KB Output is correct
2 Correct 178 ms 92368 KB Output is correct
3 Correct 169 ms 92252 KB Output is correct
4 Correct 140 ms 92100 KB Output is correct
5 Correct 143 ms 92200 KB Output is correct
6 Correct 150 ms 92064 KB Output is correct
7 Correct 140 ms 92176 KB Output is correct
8 Correct 150 ms 92364 KB Output is correct
9 Correct 158 ms 92392 KB Output is correct
10 Correct 154 ms 92424 KB Output is correct
11 Correct 162 ms 92392 KB Output is correct
12 Correct 153 ms 92208 KB Output is correct
13 Correct 155 ms 92160 KB Output is correct
14 Correct 152 ms 92244 KB Output is correct
15 Correct 156 ms 92240 KB Output is correct
16 Correct 151 ms 92264 KB Output is correct
17 Correct 154 ms 92284 KB Output is correct
18 Correct 158 ms 92264 KB Output is correct
19 Correct 1229 ms 97276 KB Output is correct
20 Correct 890 ms 97312 KB Output is correct
21 Correct 707 ms 97112 KB Output is correct
22 Correct 711 ms 96460 KB Output is correct
23 Correct 282 ms 93188 KB Output is correct
24 Correct 361 ms 93264 KB Output is correct
25 Correct 740 ms 97280 KB Output is correct
26 Correct 778 ms 97552 KB Output is correct
27 Correct 942 ms 97220 KB Output is correct
28 Correct 966 ms 97352 KB Output is correct
29 Correct 918 ms 97168 KB Output is correct
30 Correct 333 ms 93632 KB Output is correct
31 Correct 863 ms 97544 KB Output is correct
32 Correct 887 ms 97116 KB Output is correct
33 Correct 300 ms 93520 KB Output is correct
34 Correct 947 ms 97120 KB Output is correct
35 Correct 634 ms 96284 KB Output is correct
36 Correct 303 ms 93320 KB Output is correct
37 Correct 282 ms 93252 KB Output is correct
38 Correct 723 ms 97408 KB Output is correct
39 Correct 299 ms 97196 KB Output is correct
40 Correct 648 ms 96232 KB Output is correct
41 Correct 1440 ms 97324 KB Output is correct
42 Correct 65 ms 96828 KB Output is correct
43 Correct 174 ms 90828 KB Output is correct
44 Correct 198 ms 90704 KB Output is correct
45 Correct 149 ms 90760 KB Output is correct
46 Correct 127 ms 90704 KB Output is correct
47 Correct 149 ms 90708 KB Output is correct
48 Correct 150 ms 90796 KB Output is correct
49 Correct 153 ms 90724 KB Output is correct
50 Correct 144 ms 90708 KB Output is correct
51 Correct 150 ms 90704 KB Output is correct
52 Correct 149 ms 90648 KB Output is correct
53 Correct 159 ms 91104 KB Output is correct
54 Correct 127 ms 90708 KB Output is correct
55 Correct 151 ms 90840 KB Output is correct
56 Correct 151 ms 90840 KB Output is correct
57 Correct 156 ms 90808 KB Output is correct
58 Correct 147 ms 90788 KB Output is correct
59 Correct 151 ms 90704 KB Output is correct
60 Correct 160 ms 90660 KB Output is correct
61 Correct 179 ms 90640 KB Output is correct
62 Correct 154 ms 90728 KB Output is correct
63 Correct 150 ms 90712 KB Output is correct
64 Correct 166 ms 90708 KB Output is correct
65 Correct 151 ms 90860 KB Output is correct
66 Correct 155 ms 90708 KB Output is correct
67 Correct 143 ms 90708 KB Output is correct
68 Correct 153 ms 90632 KB Output is correct
69 Correct 1098 ms 96392 KB Output is correct
70 Correct 903 ms 97392 KB Output is correct
71 Correct 293 ms 93460 KB Output is correct
72 Correct 297 ms 93408 KB Output is correct
73 Correct 294 ms 93404 KB Output is correct
74 Correct 697 ms 96472 KB Output is correct
75 Correct 288 ms 93268 KB Output is correct
76 Correct 787 ms 97288 KB Output is correct
77 Correct 801 ms 96548 KB Output is correct
78 Correct 329 ms 93304 KB Output is correct
79 Correct 314 ms 93376 KB Output is correct
80 Correct 712 ms 96052 KB Output is correct
81 Correct 281 ms 93352 KB Output is correct
82 Correct 762 ms 97216 KB Output is correct
83 Correct 825 ms 97224 KB Output is correct
84 Correct 297 ms 93328 KB Output is correct
85 Correct 290 ms 93332 KB Output is correct
86 Correct 841 ms 96208 KB Output is correct
87 Correct 993 ms 97388 KB Output is correct
88 Correct 368 ms 93552 KB Output is correct
89 Correct 874 ms 96740 KB Output is correct
90 Correct 944 ms 97172 KB Output is correct
91 Correct 329 ms 93224 KB Output is correct
92 Correct 650 ms 96044 KB Output is correct
93 Correct 295 ms 93320 KB Output is correct
94 Correct 281 ms 93180 KB Output is correct
95 Correct 309 ms 93468 KB Output is correct
96 Correct 681 ms 96976 KB Output is correct
97 Correct 329 ms 97092 KB Output is correct
98 Correct 664 ms 96216 KB Output is correct
99 Correct 1432 ms 97356 KB Output is correct
100 Correct 75 ms 96776 KB Output is correct