Submission #799867

# Submission time Handle Problem Language Result Execution time Memory
799867 2023-08-01T07:21:05 Z ymm Crossing (JOI21_crossing) C++17
100 / 100
181 ms 20692 KB
#include <bits/stdc++.h>
#define Loop(x,l,r) for (ll x = (l); x < (r); ++x)
typedef long long ll;
using namespace std;

const int N = 200'010;

namespace seg {
	struct node {
		int all[3];
		int eq;
		int lzy;
	} t[4*N];
	int constexpr cnts = 9;
	int sz = 0;

	int to_num(char c) {
		return (c == 'O') + 2*(c == 'I');
	}

	void init(const string s[cnts], const string &t0, int i, int b, int e) {
		if (e-b == 1) {
			Loop (c,0,3) {
				t[i].all[c] = 0;
				Loop (j,0,cnts)
					t[i].all[c] ^= (to_num(s[j][b]) == c) << j;
			}
			t[i].eq = 0;
			Loop (j,0,cnts)
				t[i].eq ^= (s[j][b] == t0[b]) << j;
			t[i].lzy = -1;
			return;
		}
		init(s, t0, 2*i+1, b, (b+e)/2);
		init(s, t0, 2*i+2, (b+e)/2, e);
		Loop (c,0,3)
			t[i].all[c] = t[2*i+1].all[c] & t[2*i+2].all[c];
		t[i].eq = t[2*i+1].eq & t[2*i+2].eq;
		t[i].lzy = -1;
	}
	void init(const string s[cnts], const string &t) {
		sz = t.size();
		init(s, t, 0, 0, sz);
	}

	void tag(int i, int x) {
		t[i].lzy = x;
		t[i].eq = t[i].all[x];
	}

	void ppg(int i) {
		if (t[i].lzy == -1)
			return;
		tag(2*i+1, t[i].lzy);
		tag(2*i+2, t[i].lzy);
		t[i].lzy = -1;
	}

	void up(int l, int r, int x, int i, int b, int e) {
		if (l <= b && e <= r)
			return tag(i, x);
		ppg(i);
		if (l < (b+e)/2)
			up(l, r, x, 2*i+1, b, (b+e)/2);
		if ((b+e)/2 < r)
			up(l, r, x, 2*i+2, (b+e)/2, e);
		t[i].eq = t[2*i+1].eq & t[2*i+2].eq;
	}
	void up(int l, int r, char c) { up(l, r, to_num(c), 0, 0, sz); }
}


string cross(string a, string b)
{
	string ans(a.size(), '\0');
	Loop (i,0,a.size()) {
		if (a[i] == b[i])
			ans[i] = a[i];
		else if ('J' != a[i] && 'J' != b[i])
			ans[i] = 'J';
		else if ('O' != a[i] && 'O' != b[i])
			ans[i] = 'O';
		else if ('I' != a[i] && 'I' != b[i])
			ans[i] = 'I';
	}
	return ans;
}

int main()
{
	cin.tie(0) -> sync_with_stdio(false);
	string a, b, c;
	int n;
	cin >> n >> a >> b >> c;
	vector<string> vec = {a, b, c, cross(a, b), cross(b, c), cross(c, a), cross(cross(a, b), c), cross(cross(b, c), a), cross(cross(c, a), b)};
	string t0;
	int q;
	cin >> q >> t0;
	seg::init(vec.data(), t0);
	cout << (seg::t[0].eq? "Yes\n": "No\n");
	while (q--) {
		int l, r;
		char c;
		cin >> l >> r >> c;
		--l;
		seg::up(l, r, c);
		cout << (seg::t[0].eq? "Yes\n": "No\n");
	}
}

Compilation message

Main.cpp: In function 'std::string cross(std::string, std::string)':
Main.cpp:2:40: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    2 | #define Loop(x,l,r) for (ll x = (l); x < (r); ++x)
      |                                        ^
Main.cpp:76:2: note: in expansion of macro 'Loop'
   76 |  Loop (i,0,a.size()) {
      |  ^~~~
# Verdict Execution time Memory Grader output
1 Correct 43 ms 2252 KB Output is correct
2 Correct 47 ms 2368 KB Output is correct
3 Correct 47 ms 2320 KB Output is correct
4 Correct 41 ms 2364 KB Output is correct
5 Correct 39 ms 2252 KB Output is correct
6 Correct 40 ms 2312 KB Output is correct
7 Correct 41 ms 2380 KB Output is correct
8 Correct 42 ms 2384 KB Output is correct
9 Correct 42 ms 2388 KB Output is correct
10 Correct 43 ms 2392 KB Output is correct
11 Correct 44 ms 2440 KB Output is correct
12 Correct 42 ms 2444 KB Output is correct
13 Correct 53 ms 2436 KB Output is correct
14 Correct 43 ms 2404 KB Output is correct
15 Correct 49 ms 2380 KB Output is correct
16 Correct 43 ms 2380 KB Output is correct
17 Correct 44 ms 2420 KB Output is correct
18 Correct 43 ms 2268 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 43 ms 2252 KB Output is correct
2 Correct 47 ms 2368 KB Output is correct
3 Correct 47 ms 2320 KB Output is correct
4 Correct 41 ms 2364 KB Output is correct
5 Correct 39 ms 2252 KB Output is correct
6 Correct 40 ms 2312 KB Output is correct
7 Correct 41 ms 2380 KB Output is correct
8 Correct 42 ms 2384 KB Output is correct
9 Correct 42 ms 2388 KB Output is correct
10 Correct 43 ms 2392 KB Output is correct
11 Correct 44 ms 2440 KB Output is correct
12 Correct 42 ms 2444 KB Output is correct
13 Correct 53 ms 2436 KB Output is correct
14 Correct 43 ms 2404 KB Output is correct
15 Correct 49 ms 2380 KB Output is correct
16 Correct 43 ms 2380 KB Output is correct
17 Correct 44 ms 2420 KB Output is correct
18 Correct 43 ms 2268 KB Output is correct
19 Correct 143 ms 17656 KB Output is correct
20 Correct 141 ms 17464 KB Output is correct
21 Correct 114 ms 17120 KB Output is correct
22 Correct 100 ms 16756 KB Output is correct
23 Correct 65 ms 4208 KB Output is correct
24 Correct 70 ms 4212 KB Output is correct
25 Correct 115 ms 17556 KB Output is correct
26 Correct 109 ms 17600 KB Output is correct
27 Correct 122 ms 17576 KB Output is correct
28 Correct 124 ms 17544 KB Output is correct
29 Correct 120 ms 17564 KB Output is correct
30 Correct 75 ms 4244 KB Output is correct
31 Correct 119 ms 17532 KB Output is correct
32 Correct 120 ms 17040 KB Output is correct
33 Correct 67 ms 4276 KB Output is correct
34 Correct 122 ms 17580 KB Output is correct
35 Correct 94 ms 16392 KB Output is correct
36 Correct 71 ms 4188 KB Output is correct
37 Correct 66 ms 4188 KB Output is correct
38 Correct 155 ms 17380 KB Output is correct
39 Correct 93 ms 17648 KB Output is correct
40 Correct 108 ms 11436 KB Output is correct
41 Correct 155 ms 17832 KB Output is correct
42 Correct 55 ms 16984 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 43 ms 2252 KB Output is correct
2 Correct 47 ms 2368 KB Output is correct
3 Correct 47 ms 2320 KB Output is correct
4 Correct 41 ms 2364 KB Output is correct
5 Correct 39 ms 2252 KB Output is correct
6 Correct 40 ms 2312 KB Output is correct
7 Correct 41 ms 2380 KB Output is correct
8 Correct 42 ms 2384 KB Output is correct
9 Correct 42 ms 2388 KB Output is correct
10 Correct 43 ms 2392 KB Output is correct
11 Correct 44 ms 2440 KB Output is correct
12 Correct 42 ms 2444 KB Output is correct
13 Correct 53 ms 2436 KB Output is correct
14 Correct 43 ms 2404 KB Output is correct
15 Correct 49 ms 2380 KB Output is correct
16 Correct 43 ms 2380 KB Output is correct
17 Correct 44 ms 2420 KB Output is correct
18 Correct 43 ms 2268 KB Output is correct
19 Correct 45 ms 2308 KB Output is correct
20 Correct 46 ms 2240 KB Output is correct
21 Correct 54 ms 2440 KB Output is correct
22 Correct 38 ms 2248 KB Output is correct
23 Correct 42 ms 2384 KB Output is correct
24 Correct 40 ms 2300 KB Output is correct
25 Correct 52 ms 2404 KB Output is correct
26 Correct 40 ms 2336 KB Output is correct
27 Correct 53 ms 2392 KB Output is correct
28 Correct 39 ms 2220 KB Output is correct
29 Correct 50 ms 2380 KB Output is correct
30 Correct 38 ms 2232 KB Output is correct
31 Correct 42 ms 2372 KB Output is correct
32 Correct 42 ms 2380 KB Output is correct
33 Correct 45 ms 2380 KB Output is correct
34 Correct 48 ms 2248 KB Output is correct
35 Correct 43 ms 2384 KB Output is correct
36 Correct 43 ms 2380 KB Output is correct
37 Correct 43 ms 2368 KB Output is correct
38 Correct 43 ms 2376 KB Output is correct
39 Correct 49 ms 2344 KB Output is correct
40 Correct 43 ms 2444 KB Output is correct
41 Correct 43 ms 2376 KB Output is correct
42 Correct 44 ms 2348 KB Output is correct
43 Correct 41 ms 2376 KB Output is correct
44 Correct 43 ms 2452 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 43 ms 2252 KB Output is correct
2 Correct 47 ms 2368 KB Output is correct
3 Correct 47 ms 2320 KB Output is correct
4 Correct 41 ms 2364 KB Output is correct
5 Correct 39 ms 2252 KB Output is correct
6 Correct 40 ms 2312 KB Output is correct
7 Correct 41 ms 2380 KB Output is correct
8 Correct 42 ms 2384 KB Output is correct
9 Correct 42 ms 2388 KB Output is correct
10 Correct 43 ms 2392 KB Output is correct
11 Correct 44 ms 2440 KB Output is correct
12 Correct 42 ms 2444 KB Output is correct
13 Correct 53 ms 2436 KB Output is correct
14 Correct 43 ms 2404 KB Output is correct
15 Correct 49 ms 2380 KB Output is correct
16 Correct 43 ms 2380 KB Output is correct
17 Correct 44 ms 2420 KB Output is correct
18 Correct 43 ms 2268 KB Output is correct
19 Correct 143 ms 17656 KB Output is correct
20 Correct 141 ms 17464 KB Output is correct
21 Correct 114 ms 17120 KB Output is correct
22 Correct 100 ms 16756 KB Output is correct
23 Correct 65 ms 4208 KB Output is correct
24 Correct 70 ms 4212 KB Output is correct
25 Correct 115 ms 17556 KB Output is correct
26 Correct 109 ms 17600 KB Output is correct
27 Correct 122 ms 17576 KB Output is correct
28 Correct 124 ms 17544 KB Output is correct
29 Correct 120 ms 17564 KB Output is correct
30 Correct 75 ms 4244 KB Output is correct
31 Correct 119 ms 17532 KB Output is correct
32 Correct 120 ms 17040 KB Output is correct
33 Correct 67 ms 4276 KB Output is correct
34 Correct 122 ms 17580 KB Output is correct
35 Correct 94 ms 16392 KB Output is correct
36 Correct 71 ms 4188 KB Output is correct
37 Correct 66 ms 4188 KB Output is correct
38 Correct 155 ms 17380 KB Output is correct
39 Correct 93 ms 17648 KB Output is correct
40 Correct 108 ms 11436 KB Output is correct
41 Correct 155 ms 17832 KB Output is correct
42 Correct 55 ms 16984 KB Output is correct
43 Correct 45 ms 2308 KB Output is correct
44 Correct 46 ms 2240 KB Output is correct
45 Correct 54 ms 2440 KB Output is correct
46 Correct 38 ms 2248 KB Output is correct
47 Correct 42 ms 2384 KB Output is correct
48 Correct 40 ms 2300 KB Output is correct
49 Correct 52 ms 2404 KB Output is correct
50 Correct 40 ms 2336 KB Output is correct
51 Correct 53 ms 2392 KB Output is correct
52 Correct 39 ms 2220 KB Output is correct
53 Correct 50 ms 2380 KB Output is correct
54 Correct 38 ms 2232 KB Output is correct
55 Correct 42 ms 2372 KB Output is correct
56 Correct 42 ms 2380 KB Output is correct
57 Correct 45 ms 2380 KB Output is correct
58 Correct 48 ms 2248 KB Output is correct
59 Correct 43 ms 2384 KB Output is correct
60 Correct 43 ms 2380 KB Output is correct
61 Correct 43 ms 2368 KB Output is correct
62 Correct 43 ms 2376 KB Output is correct
63 Correct 49 ms 2344 KB Output is correct
64 Correct 43 ms 2444 KB Output is correct
65 Correct 43 ms 2376 KB Output is correct
66 Correct 44 ms 2348 KB Output is correct
67 Correct 41 ms 2376 KB Output is correct
68 Correct 43 ms 2452 KB Output is correct
69 Correct 145 ms 16672 KB Output is correct
70 Correct 152 ms 17504 KB Output is correct
71 Correct 67 ms 4332 KB Output is correct
72 Correct 68 ms 4232 KB Output is correct
73 Correct 66 ms 4312 KB Output is correct
74 Correct 116 ms 20692 KB Output is correct
75 Correct 66 ms 4252 KB Output is correct
76 Correct 119 ms 17664 KB Output is correct
77 Correct 108 ms 16812 KB Output is correct
78 Correct 67 ms 4356 KB Output is correct
79 Correct 67 ms 4296 KB Output is correct
80 Correct 104 ms 16204 KB Output is correct
81 Correct 66 ms 4224 KB Output is correct
82 Correct 120 ms 17616 KB Output is correct
83 Correct 118 ms 17312 KB Output is correct
84 Correct 82 ms 4264 KB Output is correct
85 Correct 66 ms 4220 KB Output is correct
86 Correct 112 ms 16564 KB Output is correct
87 Correct 133 ms 17620 KB Output is correct
88 Correct 72 ms 4308 KB Output is correct
89 Correct 111 ms 16928 KB Output is correct
90 Correct 130 ms 17640 KB Output is correct
91 Correct 75 ms 4192 KB Output is correct
92 Correct 111 ms 16360 KB Output is correct
93 Correct 67 ms 4284 KB Output is correct
94 Correct 82 ms 4208 KB Output is correct
95 Correct 71 ms 4232 KB Output is correct
96 Correct 139 ms 17380 KB Output is correct
97 Correct 99 ms 17652 KB Output is correct
98 Correct 111 ms 11264 KB Output is correct
99 Correct 181 ms 17744 KB Output is correct
100 Correct 64 ms 17032 KB Output is correct