# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
573845 | colossal_pepe | Crossing (JOI21_crossing) | C++17 | 7035 ms | 4604 KiB |
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 <iostream>
#include <vector>
#include <set>
using namespace std;
int n, q;
set<string> dict;
vector<string> all, now(3);
string t;
char crossChar(char c1, char c2) {
if (c1 == c2) return c1;
if (c1 != 'J' and c2 != 'J') return 'J';
else if (c1 != 'O' and c2 != 'O') return 'O';
else return 'I';
}
string crossStr(string s1, string s2) {
string ret;
for (int i = 0; i < s1.size(); i++) {
ret += crossChar(s1[i], s2[i]);
}
return ret;
}
void generate() {
while (not now.empty()) {
string s = now.back();
now.pop_back();
if (dict.find(s) != dict.end()) continue;
dict.insert(s);
all.push_back(s);
for (string t : all) {
now.push_back(crossStr(s, t));
}
}
}
bool check() {
for (string s : all) {
if (t == s) return 1;
}
return 0;
}
int main() {
cin >> n >> now[0] >> now[1] >> now[2];
generate();
cin >> q >> t;
cout << (check() ? "Yes" : "No") << '\n';
while (q--) {
int l, r;
char c;
cin >> l >> r >> c;
for (int i = l - 1; i <= r - 1; i++) {
t[i] = c;
}
cout << (check() ? "Yes" : "No") << '\n';
}
return 0;
}
Compilation message (stderr)
# | 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... |