//#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
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);
| ~~~~~~~^~~~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
105 ms |
852 KB |
Output is correct |
2 |
Correct |
136 ms |
868 KB |
Output is correct |
3 |
Correct |
152 ms |
1364 KB |
Output is correct |
4 |
Correct |
128 ms |
928 KB |
Output is correct |
5 |
Correct |
122 ms |
916 KB |
Output is correct |
6 |
Correct |
125 ms |
940 KB |
Output is correct |
7 |
Correct |
106 ms |
852 KB |
Output is correct |
8 |
Correct |
136 ms |
908 KB |
Output is correct |
9 |
Correct |
136 ms |
880 KB |
Output is correct |
10 |
Correct |
139 ms |
956 KB |
Output is correct |
11 |
Correct |
135 ms |
920 KB |
Output is correct |
12 |
Correct |
135 ms |
916 KB |
Output is correct |
13 |
Correct |
137 ms |
848 KB |
Output is correct |
14 |
Correct |
135 ms |
848 KB |
Output is correct |
15 |
Correct |
135 ms |
916 KB |
Output is correct |
16 |
Correct |
136 ms |
816 KB |
Output is correct |
17 |
Correct |
138 ms |
1364 KB |
Output is correct |
18 |
Correct |
146 ms |
848 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
105 ms |
852 KB |
Output is correct |
2 |
Correct |
136 ms |
868 KB |
Output is correct |
3 |
Correct |
152 ms |
1364 KB |
Output is correct |
4 |
Correct |
128 ms |
928 KB |
Output is correct |
5 |
Correct |
122 ms |
916 KB |
Output is correct |
6 |
Correct |
125 ms |
940 KB |
Output is correct |
7 |
Correct |
106 ms |
852 KB |
Output is correct |
8 |
Correct |
136 ms |
908 KB |
Output is correct |
9 |
Correct |
136 ms |
880 KB |
Output is correct |
10 |
Correct |
139 ms |
956 KB |
Output is correct |
11 |
Correct |
135 ms |
920 KB |
Output is correct |
12 |
Correct |
135 ms |
916 KB |
Output is correct |
13 |
Correct |
137 ms |
848 KB |
Output is correct |
14 |
Correct |
135 ms |
848 KB |
Output is correct |
15 |
Correct |
135 ms |
916 KB |
Output is correct |
16 |
Correct |
136 ms |
816 KB |
Output is correct |
17 |
Correct |
138 ms |
1364 KB |
Output is correct |
18 |
Correct |
146 ms |
848 KB |
Output is correct |
19 |
Execution timed out |
7028 ms |
1540 KB |
Time limit exceeded |
20 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
105 ms |
852 KB |
Output is correct |
2 |
Correct |
136 ms |
868 KB |
Output is correct |
3 |
Correct |
152 ms |
1364 KB |
Output is correct |
4 |
Correct |
128 ms |
928 KB |
Output is correct |
5 |
Correct |
122 ms |
916 KB |
Output is correct |
6 |
Correct |
125 ms |
940 KB |
Output is correct |
7 |
Correct |
106 ms |
852 KB |
Output is correct |
8 |
Correct |
136 ms |
908 KB |
Output is correct |
9 |
Correct |
136 ms |
880 KB |
Output is correct |
10 |
Correct |
139 ms |
956 KB |
Output is correct |
11 |
Correct |
135 ms |
920 KB |
Output is correct |
12 |
Correct |
135 ms |
916 KB |
Output is correct |
13 |
Correct |
137 ms |
848 KB |
Output is correct |
14 |
Correct |
135 ms |
848 KB |
Output is correct |
15 |
Correct |
135 ms |
916 KB |
Output is correct |
16 |
Correct |
136 ms |
816 KB |
Output is correct |
17 |
Correct |
138 ms |
1364 KB |
Output is correct |
18 |
Correct |
146 ms |
848 KB |
Output is correct |
19 |
Correct |
132 ms |
848 KB |
Output is correct |
20 |
Correct |
151 ms |
1012 KB |
Output is correct |
21 |
Correct |
137 ms |
852 KB |
Output is correct |
22 |
Correct |
93 ms |
932 KB |
Output is correct |
23 |
Correct |
138 ms |
848 KB |
Output is correct |
24 |
Correct |
120 ms |
876 KB |
Output is correct |
25 |
Correct |
137 ms |
908 KB |
Output is correct |
26 |
Correct |
100 ms |
836 KB |
Output is correct |
27 |
Correct |
139 ms |
1124 KB |
Output is correct |
28 |
Correct |
119 ms |
924 KB |
Output is correct |
29 |
Correct |
137 ms |
1024 KB |
Output is correct |
30 |
Correct |
94 ms |
848 KB |
Output is correct |
31 |
Correct |
140 ms |
1224 KB |
Output is correct |
32 |
Correct |
131 ms |
956 KB |
Output is correct |
33 |
Correct |
137 ms |
1116 KB |
Output is correct |
34 |
Correct |
101 ms |
908 KB |
Output is correct |
35 |
Correct |
138 ms |
800 KB |
Output is correct |
36 |
Correct |
140 ms |
832 KB |
Output is correct |
37 |
Correct |
137 ms |
1024 KB |
Output is correct |
38 |
Correct |
138 ms |
972 KB |
Output is correct |
39 |
Correct |
138 ms |
976 KB |
Output is correct |
40 |
Correct |
138 ms |
812 KB |
Output is correct |
41 |
Correct |
140 ms |
1108 KB |
Output is correct |
42 |
Correct |
143 ms |
800 KB |
Output is correct |
43 |
Correct |
113 ms |
904 KB |
Output is correct |
44 |
Correct |
138 ms |
1056 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
105 ms |
852 KB |
Output is correct |
2 |
Correct |
136 ms |
868 KB |
Output is correct |
3 |
Correct |
152 ms |
1364 KB |
Output is correct |
4 |
Correct |
128 ms |
928 KB |
Output is correct |
5 |
Correct |
122 ms |
916 KB |
Output is correct |
6 |
Correct |
125 ms |
940 KB |
Output is correct |
7 |
Correct |
106 ms |
852 KB |
Output is correct |
8 |
Correct |
136 ms |
908 KB |
Output is correct |
9 |
Correct |
136 ms |
880 KB |
Output is correct |
10 |
Correct |
139 ms |
956 KB |
Output is correct |
11 |
Correct |
135 ms |
920 KB |
Output is correct |
12 |
Correct |
135 ms |
916 KB |
Output is correct |
13 |
Correct |
137 ms |
848 KB |
Output is correct |
14 |
Correct |
135 ms |
848 KB |
Output is correct |
15 |
Correct |
135 ms |
916 KB |
Output is correct |
16 |
Correct |
136 ms |
816 KB |
Output is correct |
17 |
Correct |
138 ms |
1364 KB |
Output is correct |
18 |
Correct |
146 ms |
848 KB |
Output is correct |
19 |
Execution timed out |
7028 ms |
1540 KB |
Time limit exceeded |
20 |
Halted |
0 ms |
0 KB |
- |