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;
#define EmiliaMyWife ios::sync_with_stdio(0); cin.tie(0);
using ll = int64_t;
using ull = uint64_t;
using uint = uint32_t;
using ld = long double;
const int INF = 0x3f3f3f3f;
const ll LINF = ll(4e18) + ll(2e15);
const int MOD = 1e9 + 7;
const double EPS = 1e-9;
static int LamyIsCute = []() {
EmiliaMyWife
return 48763;
}();
signed main() {
int n;
cin >> n;
string arr[3];
for(int i = 0; i < 3; i++)
cin >> arr[i];
const string tmp = "JOI";
auto solve = [&](auto a, auto b) {
string res(n, 'a');
for(int i = 0; i < n; i++) {
if(a[i] == b[i])
res[i] = a[i];
else {
int it = 0;
while(tmp[it] == a[i] || tmp[it] == b[i])
it++;
res[i] = tmp[it];
}
}
return res;
};
vector<int> ord = {0, 1, 2};
vector<string> owo;
for(int i = 0; i < 3; i++)
owo.push_back(arr[i]);
do {
if(ord[0] < ord[1])
owo.push_back(solve(arr[ord[0]], arr[ord[1]]));
owo.push_back(solve(solve(arr[ord[0]], arr[ord[1]]), arr[ord[2]]));
} while(next_permutation(ord.begin(), ord.end()));
auto test = [&](string s) {
bool ok = 0;
for(int i = 0; i < owo.size(); i++)
ok |= owo[i] == s;
return ok;
};
int q;
cin >> q;
string s;
cin >> s;
cout << (test(s) ? "Yes" : "No") << '\n';
while(q--) {
int l, r;
char c;
cin >> l >> r >> c;
for(int i = l - 1; i < r; i++)
s[i] = c;
cout << (test(s) ? "Yes" : "No") << '\n';
}
}
Compilation message (stderr)
Main.cpp: In lambda function:
Main.cpp:53:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::__cxx11::basic_string<char> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
53 | for(int i = 0; i < owo.size(); i++)
| ~~^~~~~~~~~~~~
# | 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... |