This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,sse,sse2,sse3,ssse3,sse4,abm,popcnt,mmx")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
typedef long double ldb;
typedef complex<double> cd;
constexpr ll INF64 = 9'000'000'000'000'000'000, INF32 = 2'000'000'000, MOD = 1'000'000'007, p = 57;
constexpr db PI = acos(-1);
constexpr bool IS_FILE = false, IS_TEST_CASES = false;
random_device rd;
mt19937 rnd32(rd());
mt19937_64 rnd64(rd());
template<typename T>
bool assign_max(T& a, T b) {
if (b > a) {
a = b;
return true;
}
return false;
}
template<typename T>
bool assign_min(T& a, T b) {
if (b < a) {
a = b;
return true;
}
return false;
}
template<typename T>
T square(T a) {
return a * a;
}
template<>
struct std::hash<pair<ll, ll>> {
ll operator() (pair<ll, ll> p) const {
return ((__int128)p.first * MOD + p.second) % INF64;
}
};
map<pair<char, char>, char> m;
set<ll> can;
string make(string& s1, string& s2) {
string ans(s1.size(), '.');
for (ll i = 0; i < s1.size(); i++) {
ans[i] = m[make_pair(s1[i], s2[i])];
}
return ans;
}
ll calc(string& s) {
ll ans = 0, now = 1;
for (auto i : s) {
ans += (i - 'A') * now;
ans %= MOD;
now *= p;
now %= MOD;
}
return ans;
}
void rec(string& s, string& s1, string& s2, string& s3) {
can.insert(calc(s));
s = make(s, s1);
if (can.find(calc(s)) == can.end()) {
rec(s, s1, s2, s3);
}
s = make(s, s1);
s = make(s, s2);
if (can.find(calc(s)) == can.end()) {
rec(s, s1, s2, s3);
}
s = make(s, s2);
s = make(s, s3);
if (can.find(calc(s)) == can.end()) {
rec(s, s1, s2, s3);
}
s = make(s, s3);
}
void solve() {
m[make_pair('O', 'O')] = 'O';
m[make_pair('O', 'I')] = 'J';
m[make_pair('O', 'J')] = 'I';
m[make_pair('I', 'O')] = 'J';
m[make_pair('I', 'I')] = 'I';
m[make_pair('I', 'J')] = 'O';
m[make_pair('J', 'O')] = 'I';
m[make_pair('J', 'I')] = 'O';
m[make_pair('J', 'J')] = 'J';
ll n;
cin >> n;
string s1, s2, s3;
cin >> s1 >> s2 >> s3;
string s = s1;
rec(s, s1, s2, s3);
ll q;
cin >> q;
cin >> s;
cout << (can.find(calc(s)) == can.end() ? "No" : "Yes") << '\n';
for (ll i = 0; i < q; i++) {
ll l, r;
char c;
cin >> l >> r >> c;
l--;
for (ll j = l; j < r; j++) {
s[j] = c;
}
cout << (can.find(calc(s)) == can.end() ? "No" : "Yes") << '\n';
}
}
int main() {
if (IS_FILE) {
freopen("", "r", stdin);
freopen("", "w", stdout);
}
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
ll t = 1;
if (IS_TEST_CASES) {
cin >> t;
}
for (ll i = 0; i < t; i++) {
solve();
}
}
Compilation message (stderr)
Main.cpp: In function 'std::string make(std::string&, std::string&)':
Main.cpp:56:26: 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]
56 | for (ll i = 0; i < s1.size(); i++) {
| ~~^~~~~~~~~~~
Main.cpp: In function 'int main()':
Main.cpp:126:24: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
126 | freopen("", "r", stdin);
| ~~~~~~~^~~~~~~~~~~~~~~~
Main.cpp:127:24: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
127 | freopen("", "w", stdout);
| ~~~~~~~^~~~~~~~~~~~~~~~~
# | 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... |