#include <bits/stdc++.h>
#include <fstream>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/trie_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
template<class A, class B>
ostream& operator<<(ostream& o, const pair<A, B>& p) {return o << '(' << p.first << ", " << p.second << ')';}
template<size_t Index = 0, typename... Types>
ostream& printTupleElements(ostream& o, const tuple<Types...>& t) {if constexpr (Index < sizeof...(Types)){if(Index > 0){o << ", ";}o << get<Index>(t);printTupleElements<Index + 1>(o, t);}return o;}
template<typename... Types>
ostream& operator<<(ostream& o, const tuple<Types...>& t){o << "(";printTupleElements(o, t);return o << ")";}
template<class T>
auto operator<<(ostream& o, const T& x) -> decltype(x.end(), o){o << '{';bool first = true;for (const auto& e : x){if (!first){o << ", ";}o << e;first = false;} return o << '}';}
#define DEBUG
#ifdef DEBUG
#define fastio()
#define debug(x...) cerr << "[" #x "]: ", [](auto... $) {((cerr << $ << "; "), ...); }(x), cerr << '\n'
#define check(x) if (!(x)) { cerr << "Check failed: " << #x << " in line " << __LINE__ << endl; exit(1); }
#else
#define fastio() ios_base::sync_with_stdio(0); cin.tie(0);
#define debug(...)
#define check(x)
#endif
typedef long long ll;
#define pi pair<int, int>
#define pll pair<ll, ll>
#define st first
#define nd second
#define vi vector<int>
#define vll vector<ll>
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
void wypisz(string a) {
for(auto x : a) {
cout << x;
}
cout << '\n';
}
vector<char>lit = {'J', 'O', 'I'};
string comb(string a, string b) {
string res = "";
for(int i = 0; i < sz(a); i++) {
if(a[i] == b[i]) {
res += a[i];
}
else {
for(auto x : lit) {
if(x != a[i] && x != b[i]) {
res += x;
}
}
}
}
return res;
}
void solve() {
//ifstream cin("nazwa.in");
//ofstream cout("nazwa.out");
int n;
cin >> n;
string a, b, c;
cin >> a >> b >> c;
set<string>kt;
for(int mask = 1; mask < (1 << 3); mask++) {
vector<string>per;
if(mask & (1 << 0)) {
per.eb(a);
}
if(mask & (1 << 1)) {
per.eb(b);
}
if(mask & (1 << 2)) {
per.eb(c);
}
sort(all(per));
do {
string akt = per[0];
for(int i = 1; i < sz(per); i++) {
akt = comb(akt, per[i]);
}
kt.insert(akt);
}while(next_permutation(all(per)));
}
int t;
cin >> t;
string s;
cin >> s;
while(t >= 0) {
bool czy = 0;
for(auto x : kt) {
if(x == s) {
czy = 1;
}
}
if(czy) {
cout << "Yes\n";
}
else {
cout << "No\n";
}
if(t > 0) {
int l, r;
char zn;
cin >> l >> r >> zn;
for(int i = l - 1; i < r; i++) {
s[i] = zn;
}
}
t--;
}
}
int main() {
fastio();
int t = 1;
//cin >> t;
while(t--) {
solve();
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
278 ms |
736 KB |
Output is correct |
2 |
Correct |
299 ms |
852 KB |
Output is correct |
3 |
Correct |
316 ms |
852 KB |
Output is correct |
4 |
Correct |
291 ms |
848 KB |
Output is correct |
5 |
Correct |
289 ms |
984 KB |
Output is correct |
6 |
Correct |
290 ms |
988 KB |
Output is correct |
7 |
Correct |
298 ms |
956 KB |
Output is correct |
8 |
Correct |
307 ms |
852 KB |
Output is correct |
9 |
Correct |
307 ms |
848 KB |
Output is correct |
10 |
Correct |
311 ms |
1168 KB |
Output is correct |
11 |
Correct |
300 ms |
976 KB |
Output is correct |
12 |
Correct |
309 ms |
848 KB |
Output is correct |
13 |
Correct |
299 ms |
804 KB |
Output is correct |
14 |
Correct |
302 ms |
952 KB |
Output is correct |
15 |
Correct |
306 ms |
1040 KB |
Output is correct |
16 |
Correct |
302 ms |
792 KB |
Output is correct |
17 |
Correct |
310 ms |
1212 KB |
Output is correct |
18 |
Correct |
316 ms |
912 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
278 ms |
736 KB |
Output is correct |
2 |
Correct |
299 ms |
852 KB |
Output is correct |
3 |
Correct |
316 ms |
852 KB |
Output is correct |
4 |
Correct |
291 ms |
848 KB |
Output is correct |
5 |
Correct |
289 ms |
984 KB |
Output is correct |
6 |
Correct |
290 ms |
988 KB |
Output is correct |
7 |
Correct |
298 ms |
956 KB |
Output is correct |
8 |
Correct |
307 ms |
852 KB |
Output is correct |
9 |
Correct |
307 ms |
848 KB |
Output is correct |
10 |
Correct |
311 ms |
1168 KB |
Output is correct |
11 |
Correct |
300 ms |
976 KB |
Output is correct |
12 |
Correct |
309 ms |
848 KB |
Output is correct |
13 |
Correct |
299 ms |
804 KB |
Output is correct |
14 |
Correct |
302 ms |
952 KB |
Output is correct |
15 |
Correct |
306 ms |
1040 KB |
Output is correct |
16 |
Correct |
302 ms |
792 KB |
Output is correct |
17 |
Correct |
310 ms |
1212 KB |
Output is correct |
18 |
Correct |
316 ms |
912 KB |
Output is correct |
19 |
Correct |
4584 ms |
3028 KB |
Output is correct |
20 |
Execution timed out |
7033 ms |
2900 KB |
Time limit exceeded |
21 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
278 ms |
736 KB |
Output is correct |
2 |
Correct |
299 ms |
852 KB |
Output is correct |
3 |
Correct |
316 ms |
852 KB |
Output is correct |
4 |
Correct |
291 ms |
848 KB |
Output is correct |
5 |
Correct |
289 ms |
984 KB |
Output is correct |
6 |
Correct |
290 ms |
988 KB |
Output is correct |
7 |
Correct |
298 ms |
956 KB |
Output is correct |
8 |
Correct |
307 ms |
852 KB |
Output is correct |
9 |
Correct |
307 ms |
848 KB |
Output is correct |
10 |
Correct |
311 ms |
1168 KB |
Output is correct |
11 |
Correct |
300 ms |
976 KB |
Output is correct |
12 |
Correct |
309 ms |
848 KB |
Output is correct |
13 |
Correct |
299 ms |
804 KB |
Output is correct |
14 |
Correct |
302 ms |
952 KB |
Output is correct |
15 |
Correct |
306 ms |
1040 KB |
Output is correct |
16 |
Correct |
302 ms |
792 KB |
Output is correct |
17 |
Correct |
310 ms |
1212 KB |
Output is correct |
18 |
Correct |
316 ms |
912 KB |
Output is correct |
19 |
Correct |
332 ms |
852 KB |
Output is correct |
20 |
Correct |
359 ms |
848 KB |
Output is correct |
21 |
Correct |
312 ms |
1000 KB |
Output is correct |
22 |
Correct |
286 ms |
952 KB |
Output is correct |
23 |
Correct |
319 ms |
848 KB |
Output is correct |
24 |
Correct |
310 ms |
1004 KB |
Output is correct |
25 |
Correct |
325 ms |
848 KB |
Output is correct |
26 |
Correct |
300 ms |
888 KB |
Output is correct |
27 |
Correct |
323 ms |
1016 KB |
Output is correct |
28 |
Correct |
427 ms |
852 KB |
Output is correct |
29 |
Correct |
312 ms |
828 KB |
Output is correct |
30 |
Correct |
323 ms |
748 KB |
Output is correct |
31 |
Correct |
423 ms |
832 KB |
Output is correct |
32 |
Correct |
430 ms |
824 KB |
Output is correct |
33 |
Correct |
375 ms |
1320 KB |
Output is correct |
34 |
Correct |
372 ms |
2376 KB |
Output is correct |
35 |
Correct |
392 ms |
2464 KB |
Output is correct |
36 |
Correct |
368 ms |
2512 KB |
Output is correct |
37 |
Correct |
376 ms |
2540 KB |
Output is correct |
38 |
Correct |
359 ms |
2544 KB |
Output is correct |
39 |
Correct |
363 ms |
2384 KB |
Output is correct |
40 |
Correct |
361 ms |
2508 KB |
Output is correct |
41 |
Correct |
383 ms |
2320 KB |
Output is correct |
42 |
Correct |
398 ms |
2384 KB |
Output is correct |
43 |
Correct |
389 ms |
2468 KB |
Output is correct |
44 |
Correct |
408 ms |
2384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
278 ms |
736 KB |
Output is correct |
2 |
Correct |
299 ms |
852 KB |
Output is correct |
3 |
Correct |
316 ms |
852 KB |
Output is correct |
4 |
Correct |
291 ms |
848 KB |
Output is correct |
5 |
Correct |
289 ms |
984 KB |
Output is correct |
6 |
Correct |
290 ms |
988 KB |
Output is correct |
7 |
Correct |
298 ms |
956 KB |
Output is correct |
8 |
Correct |
307 ms |
852 KB |
Output is correct |
9 |
Correct |
307 ms |
848 KB |
Output is correct |
10 |
Correct |
311 ms |
1168 KB |
Output is correct |
11 |
Correct |
300 ms |
976 KB |
Output is correct |
12 |
Correct |
309 ms |
848 KB |
Output is correct |
13 |
Correct |
299 ms |
804 KB |
Output is correct |
14 |
Correct |
302 ms |
952 KB |
Output is correct |
15 |
Correct |
306 ms |
1040 KB |
Output is correct |
16 |
Correct |
302 ms |
792 KB |
Output is correct |
17 |
Correct |
310 ms |
1212 KB |
Output is correct |
18 |
Correct |
316 ms |
912 KB |
Output is correct |
19 |
Correct |
4584 ms |
3028 KB |
Output is correct |
20 |
Execution timed out |
7033 ms |
2900 KB |
Time limit exceeded |
21 |
Halted |
0 ms |
0 KB |
- |