# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
887147 |
2023-12-13T21:35:14 Z |
box |
Crossing (JOI21_crossing) |
C++17 |
|
7000 ms |
5916 KB |
#include <bits/stdc++.h>
using namespace std;
#define sz(v) int(std::size(v))
using i64 = long long;
const int N = 2e5, P1 = 1e9 + 7, P2 = 1e9 + 9;
string operator+(string one, const string two) {
static char all = 'J' ^ 'O' ^ 'I';
for (int i = 0; i < sz(one); i++)
one[i] = one[i] == two[i] ? one[i] : (one[i] ^ two[i] ^ all);
return one;
}
i64 hsh(const string s) {
i64 one = 0, two = 0;
for (char c : s) {
int i = c == 'J' ? 0 : c == 'O' ? 1 : 2;
one = (one * 3 + i) % P1;
two = (two * 3 + i) % P2;
}
return one * P2 + two;
}
mt19937 rng(1234);
string gen(int n) {
string s(n, '?');
for (int i = 0; i < n; i++) s[i] = "JOI"[rng() % 3];
return s;
}
int n, q;
vector<string> v;
unordered_set<i64> s;
void expand() {
for (string t : v) s.insert(hsh(t));
while (1) {
int m = sz(v);
for (int i = 0; i < m; i++) for (int j = i + 1; j < m; j++) {
string t = v[i] + v[j];
i64 h = hsh(t);
if (!s.count(h)) {
s.insert(h);
v.push_back(t);
}
}
if (sz(v) == m) break;
}
}
bool qry(const string t) {
for (string s : v) if (t == s) return true;
return false;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cin >> n;
for (int rep = 0; rep < 3; rep++) {
string s;
cin >> s;
v.push_back(s);
}
expand();
cin >> q;
string t;
cin >> t;
cout << (qry(t) ? "Yes\n" : "No\n");
while (q--) {
int l, r; char c;
cin >> l >> r >> c, l--, r--;
for (int i = l; i <= r; i++) t[i] = c;
cout << (qry(t) ? "Yes\n" : "No\n");
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
49 ms |
848 KB |
Output is correct |
2 |
Correct |
63 ms |
1188 KB |
Output is correct |
3 |
Correct |
67 ms |
796 KB |
Output is correct |
4 |
Correct |
55 ms |
852 KB |
Output is correct |
5 |
Correct |
52 ms |
896 KB |
Output is correct |
6 |
Correct |
50 ms |
860 KB |
Output is correct |
7 |
Correct |
63 ms |
1100 KB |
Output is correct |
8 |
Correct |
53 ms |
1040 KB |
Output is correct |
9 |
Correct |
54 ms |
996 KB |
Output is correct |
10 |
Correct |
53 ms |
848 KB |
Output is correct |
11 |
Correct |
68 ms |
2364 KB |
Output is correct |
12 |
Correct |
55 ms |
2560 KB |
Output is correct |
13 |
Correct |
56 ms |
2392 KB |
Output is correct |
14 |
Correct |
54 ms |
2568 KB |
Output is correct |
15 |
Correct |
69 ms |
2528 KB |
Output is correct |
16 |
Correct |
59 ms |
2384 KB |
Output is correct |
17 |
Correct |
67 ms |
2492 KB |
Output is correct |
18 |
Correct |
64 ms |
2380 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
49 ms |
848 KB |
Output is correct |
2 |
Correct |
63 ms |
1188 KB |
Output is correct |
3 |
Correct |
67 ms |
796 KB |
Output is correct |
4 |
Correct |
55 ms |
852 KB |
Output is correct |
5 |
Correct |
52 ms |
896 KB |
Output is correct |
6 |
Correct |
50 ms |
860 KB |
Output is correct |
7 |
Correct |
63 ms |
1100 KB |
Output is correct |
8 |
Correct |
53 ms |
1040 KB |
Output is correct |
9 |
Correct |
54 ms |
996 KB |
Output is correct |
10 |
Correct |
53 ms |
848 KB |
Output is correct |
11 |
Correct |
68 ms |
2364 KB |
Output is correct |
12 |
Correct |
55 ms |
2560 KB |
Output is correct |
13 |
Correct |
56 ms |
2392 KB |
Output is correct |
14 |
Correct |
54 ms |
2568 KB |
Output is correct |
15 |
Correct |
69 ms |
2528 KB |
Output is correct |
16 |
Correct |
59 ms |
2384 KB |
Output is correct |
17 |
Correct |
67 ms |
2492 KB |
Output is correct |
18 |
Correct |
64 ms |
2380 KB |
Output is correct |
19 |
Execution timed out |
7094 ms |
5916 KB |
Time limit exceeded |
20 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
49 ms |
848 KB |
Output is correct |
2 |
Correct |
63 ms |
1188 KB |
Output is correct |
3 |
Correct |
67 ms |
796 KB |
Output is correct |
4 |
Correct |
55 ms |
852 KB |
Output is correct |
5 |
Correct |
52 ms |
896 KB |
Output is correct |
6 |
Correct |
50 ms |
860 KB |
Output is correct |
7 |
Correct |
63 ms |
1100 KB |
Output is correct |
8 |
Correct |
53 ms |
1040 KB |
Output is correct |
9 |
Correct |
54 ms |
996 KB |
Output is correct |
10 |
Correct |
53 ms |
848 KB |
Output is correct |
11 |
Correct |
68 ms |
2364 KB |
Output is correct |
12 |
Correct |
55 ms |
2560 KB |
Output is correct |
13 |
Correct |
56 ms |
2392 KB |
Output is correct |
14 |
Correct |
54 ms |
2568 KB |
Output is correct |
15 |
Correct |
69 ms |
2528 KB |
Output is correct |
16 |
Correct |
59 ms |
2384 KB |
Output is correct |
17 |
Correct |
67 ms |
2492 KB |
Output is correct |
18 |
Correct |
64 ms |
2380 KB |
Output is correct |
19 |
Correct |
94 ms |
2256 KB |
Output is correct |
20 |
Correct |
109 ms |
2276 KB |
Output is correct |
21 |
Correct |
60 ms |
2388 KB |
Output is correct |
22 |
Correct |
55 ms |
2420 KB |
Output is correct |
23 |
Correct |
60 ms |
2472 KB |
Output is correct |
24 |
Correct |
63 ms |
2464 KB |
Output is correct |
25 |
Correct |
61 ms |
2524 KB |
Output is correct |
26 |
Correct |
61 ms |
2412 KB |
Output is correct |
27 |
Correct |
53 ms |
2380 KB |
Output is correct |
28 |
Correct |
53 ms |
2132 KB |
Output is correct |
29 |
Correct |
60 ms |
2564 KB |
Output is correct |
30 |
Correct |
49 ms |
2388 KB |
Output is correct |
31 |
Correct |
88 ms |
2388 KB |
Output is correct |
32 |
Correct |
83 ms |
2372 KB |
Output is correct |
33 |
Correct |
85 ms |
2372 KB |
Output is correct |
34 |
Correct |
79 ms |
2424 KB |
Output is correct |
35 |
Correct |
86 ms |
2384 KB |
Output is correct |
36 |
Correct |
91 ms |
2352 KB |
Output is correct |
37 |
Correct |
86 ms |
2384 KB |
Output is correct |
38 |
Correct |
86 ms |
2500 KB |
Output is correct |
39 |
Correct |
86 ms |
2576 KB |
Output is correct |
40 |
Correct |
107 ms |
2384 KB |
Output is correct |
41 |
Correct |
85 ms |
2344 KB |
Output is correct |
42 |
Correct |
94 ms |
2388 KB |
Output is correct |
43 |
Correct |
83 ms |
2388 KB |
Output is correct |
44 |
Correct |
84 ms |
2388 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
49 ms |
848 KB |
Output is correct |
2 |
Correct |
63 ms |
1188 KB |
Output is correct |
3 |
Correct |
67 ms |
796 KB |
Output is correct |
4 |
Correct |
55 ms |
852 KB |
Output is correct |
5 |
Correct |
52 ms |
896 KB |
Output is correct |
6 |
Correct |
50 ms |
860 KB |
Output is correct |
7 |
Correct |
63 ms |
1100 KB |
Output is correct |
8 |
Correct |
53 ms |
1040 KB |
Output is correct |
9 |
Correct |
54 ms |
996 KB |
Output is correct |
10 |
Correct |
53 ms |
848 KB |
Output is correct |
11 |
Correct |
68 ms |
2364 KB |
Output is correct |
12 |
Correct |
55 ms |
2560 KB |
Output is correct |
13 |
Correct |
56 ms |
2392 KB |
Output is correct |
14 |
Correct |
54 ms |
2568 KB |
Output is correct |
15 |
Correct |
69 ms |
2528 KB |
Output is correct |
16 |
Correct |
59 ms |
2384 KB |
Output is correct |
17 |
Correct |
67 ms |
2492 KB |
Output is correct |
18 |
Correct |
64 ms |
2380 KB |
Output is correct |
19 |
Execution timed out |
7094 ms |
5916 KB |
Time limit exceeded |
20 |
Halted |
0 ms |
0 KB |
- |