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;
void solve() {
int n;
cin >> n;
string a, b, c;
cin >> a >> b >> c;
auto cross = [&](string a, string b) {
string c = "";
for (int i = 0; i < n; ++i) {
if (a[i] == b[i]) {
c += a[i];
} else {
if (a[i] != 'J' && b[i] != 'J') {
c += 'J';
} else if (a[i] != 'O' && b[i] != 'O') {
c += 'O';
} else {
c += 'I';
}
}
}
return c;
};
vector<string> nw = {a, b, c};
for (int i = 0; i < (int)nw.size(); ++i) {
for (int j = 0; j < i; ++j) {
string add = cross(nw[i], nw[j]);
if (!count(nw.begin(), nw.end(), add)) {
nw.push_back(add);
}
}
}
int q;
cin >> q;
string t;
cin >> t;
if (count(nw.begin(), nw.end(), t)) {
cout << "Yes\n";
} else {
cout << "No\n";
}
while (q--) {
int l, r;
char ch;
cin >> l >> r >> ch;
l--;
for (int i = l; i < r; ++i) {
t[i] = ch;
}
if (count(nw.begin(), nw.end(), t)) {
cout << "Yes\n";
} else {
cout << "No\n";
}
}
}
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int t = 1;
// cin >> t;
while (t--) {
solve();
}
return 0;
}
# | 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... |