#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 |
313 ms |
852 KB |
Output is correct |
2 |
Correct |
372 ms |
792 KB |
Output is correct |
3 |
Correct |
400 ms |
848 KB |
Output is correct |
4 |
Correct |
313 ms |
1316 KB |
Output is correct |
5 |
Correct |
333 ms |
768 KB |
Output is correct |
6 |
Correct |
319 ms |
752 KB |
Output is correct |
7 |
Correct |
308 ms |
852 KB |
Output is correct |
8 |
Correct |
333 ms |
940 KB |
Output is correct |
9 |
Correct |
311 ms |
848 KB |
Output is correct |
10 |
Correct |
321 ms |
852 KB |
Output is correct |
11 |
Correct |
313 ms |
928 KB |
Output is correct |
12 |
Correct |
308 ms |
908 KB |
Output is correct |
13 |
Correct |
336 ms |
920 KB |
Output is correct |
14 |
Correct |
333 ms |
1000 KB |
Output is correct |
15 |
Correct |
336 ms |
848 KB |
Output is correct |
16 |
Correct |
357 ms |
808 KB |
Output is correct |
17 |
Correct |
301 ms |
988 KB |
Output is correct |
18 |
Correct |
314 ms |
852 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
313 ms |
852 KB |
Output is correct |
2 |
Correct |
372 ms |
792 KB |
Output is correct |
3 |
Correct |
400 ms |
848 KB |
Output is correct |
4 |
Correct |
313 ms |
1316 KB |
Output is correct |
5 |
Correct |
333 ms |
768 KB |
Output is correct |
6 |
Correct |
319 ms |
752 KB |
Output is correct |
7 |
Correct |
308 ms |
852 KB |
Output is correct |
8 |
Correct |
333 ms |
940 KB |
Output is correct |
9 |
Correct |
311 ms |
848 KB |
Output is correct |
10 |
Correct |
321 ms |
852 KB |
Output is correct |
11 |
Correct |
313 ms |
928 KB |
Output is correct |
12 |
Correct |
308 ms |
908 KB |
Output is correct |
13 |
Correct |
336 ms |
920 KB |
Output is correct |
14 |
Correct |
333 ms |
1000 KB |
Output is correct |
15 |
Correct |
336 ms |
848 KB |
Output is correct |
16 |
Correct |
357 ms |
808 KB |
Output is correct |
17 |
Correct |
301 ms |
988 KB |
Output is correct |
18 |
Correct |
314 ms |
852 KB |
Output is correct |
19 |
Correct |
6122 ms |
3424 KB |
Output is correct |
20 |
Execution timed out |
7010 ms |
3044 KB |
Time limit exceeded |
21 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
313 ms |
852 KB |
Output is correct |
2 |
Correct |
372 ms |
792 KB |
Output is correct |
3 |
Correct |
400 ms |
848 KB |
Output is correct |
4 |
Correct |
313 ms |
1316 KB |
Output is correct |
5 |
Correct |
333 ms |
768 KB |
Output is correct |
6 |
Correct |
319 ms |
752 KB |
Output is correct |
7 |
Correct |
308 ms |
852 KB |
Output is correct |
8 |
Correct |
333 ms |
940 KB |
Output is correct |
9 |
Correct |
311 ms |
848 KB |
Output is correct |
10 |
Correct |
321 ms |
852 KB |
Output is correct |
11 |
Correct |
313 ms |
928 KB |
Output is correct |
12 |
Correct |
308 ms |
908 KB |
Output is correct |
13 |
Correct |
336 ms |
920 KB |
Output is correct |
14 |
Correct |
333 ms |
1000 KB |
Output is correct |
15 |
Correct |
336 ms |
848 KB |
Output is correct |
16 |
Correct |
357 ms |
808 KB |
Output is correct |
17 |
Correct |
301 ms |
988 KB |
Output is correct |
18 |
Correct |
314 ms |
852 KB |
Output is correct |
19 |
Correct |
345 ms |
884 KB |
Output is correct |
20 |
Correct |
383 ms |
984 KB |
Output is correct |
21 |
Correct |
312 ms |
984 KB |
Output is correct |
22 |
Correct |
294 ms |
868 KB |
Output is correct |
23 |
Correct |
313 ms |
780 KB |
Output is correct |
24 |
Correct |
311 ms |
996 KB |
Output is correct |
25 |
Correct |
316 ms |
812 KB |
Output is correct |
26 |
Correct |
305 ms |
1104 KB |
Output is correct |
27 |
Correct |
314 ms |
848 KB |
Output is correct |
28 |
Correct |
285 ms |
756 KB |
Output is correct |
29 |
Correct |
314 ms |
852 KB |
Output is correct |
30 |
Correct |
293 ms |
848 KB |
Output is correct |
31 |
Correct |
357 ms |
1184 KB |
Output is correct |
32 |
Correct |
350 ms |
848 KB |
Output is correct |
33 |
Correct |
349 ms |
852 KB |
Output is correct |
34 |
Correct |
330 ms |
796 KB |
Output is correct |
35 |
Correct |
380 ms |
1016 KB |
Output is correct |
36 |
Correct |
353 ms |
960 KB |
Output is correct |
37 |
Correct |
353 ms |
792 KB |
Output is correct |
38 |
Correct |
350 ms |
912 KB |
Output is correct |
39 |
Correct |
364 ms |
1000 KB |
Output is correct |
40 |
Correct |
372 ms |
980 KB |
Output is correct |
41 |
Correct |
364 ms |
1000 KB |
Output is correct |
42 |
Correct |
375 ms |
852 KB |
Output is correct |
43 |
Correct |
481 ms |
828 KB |
Output is correct |
44 |
Correct |
359 ms |
1184 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
313 ms |
852 KB |
Output is correct |
2 |
Correct |
372 ms |
792 KB |
Output is correct |
3 |
Correct |
400 ms |
848 KB |
Output is correct |
4 |
Correct |
313 ms |
1316 KB |
Output is correct |
5 |
Correct |
333 ms |
768 KB |
Output is correct |
6 |
Correct |
319 ms |
752 KB |
Output is correct |
7 |
Correct |
308 ms |
852 KB |
Output is correct |
8 |
Correct |
333 ms |
940 KB |
Output is correct |
9 |
Correct |
311 ms |
848 KB |
Output is correct |
10 |
Correct |
321 ms |
852 KB |
Output is correct |
11 |
Correct |
313 ms |
928 KB |
Output is correct |
12 |
Correct |
308 ms |
908 KB |
Output is correct |
13 |
Correct |
336 ms |
920 KB |
Output is correct |
14 |
Correct |
333 ms |
1000 KB |
Output is correct |
15 |
Correct |
336 ms |
848 KB |
Output is correct |
16 |
Correct |
357 ms |
808 KB |
Output is correct |
17 |
Correct |
301 ms |
988 KB |
Output is correct |
18 |
Correct |
314 ms |
852 KB |
Output is correct |
19 |
Correct |
6122 ms |
3424 KB |
Output is correct |
20 |
Execution timed out |
7010 ms |
3044 KB |
Time limit exceeded |
21 |
Halted |
0 ms |
0 KB |
- |