# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
680372 | bashkort | Crossing (JOI21_crossing) | C++17 | 7034 ms | 4276 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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;
}
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);
}
}
}
int q;
cin >> q;
string t;
cin >> t;
cout << (every.count(t) ? "Yes\n" : "No\n");
while (q--) {
int l, r;
char c;
cin >> l >> r >> c;
--l;
for (int i = l; i < r; ++i) {
t[i] = c;
}
cout << (every.count(t) ? "Yes\n" : "No\n");
}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |