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 <bits/stdc++.h>
struct ter {
ter(const std::string& seqq) {
seq = "";
for (int i = 0; i < (int)seqq.size(); ++i) {
char q = seqq[i];
int dig = 1;
if (q == 'O') {
dig = 0;
}
else if (q == 'I') {
dig = 2;
}
seq += '0' + dig;
}
}
ter operator *(int a) {
ter temp = *this;
for (int i = 0; i < (int)seq.size(); ++i) {
int dig = temp.seq[i] - '0';
dig *= a;
dig %= 3;
temp.seq[i] = '0' + dig;
}
return temp;
}
ter operator +(const ter& a) {
ter temp = *this;
for (int i = 0; i < (int)seq.size(); ++i) {
int dig = temp.seq[i] + a.seq[i] - 2 * '0';
dig %= 3;
temp.seq[i] = '0' + dig;
}
return temp;
}
std::string seq;
};
int main() {
std::string a, b, c;
std::set<std::string> all;
int n;
std::cin >> n;
std::cin >> a >> b >> c;
ter aa(a), bb(b), cc(c);
all.insert({ aa.seq, bb.seq, cc.seq, ((aa + bb) * 2).seq, ((aa + cc) * 2).seq, ((cc + bb) * 2).seq });
all.insert({ (aa + bb + cc*2).seq, (aa + cc + bb * 2).seq, (cc + bb + aa * 2).seq });
//std::cout << "ALL POSSIBLE ANSWERES ARE" << std::endl;
//for (const auto& s : all) {
// std::cout << s << std::endl;
//}
//std::cout << "#####" << std::endl;
int q;
std::cin >> q;
std::string s;
std::cin >> s;
std::cout << /*"S is obtainable? " << */ ((all.find(ter(s).seq) == all.end()) ? "No" : "Yes") << std::endl;
while (q--) {
int l, r;
std::cin >> l >> r;
char q;
std::cin >> q;
int dig = 1;
if (q == 'O') {
dig = 0;
}
else if (q == 'I'){
dig = 2;
}
for (int i = l - 1; i < r; ++i) {
s[i] = dig + '0';
}
//std::cout << "S is " << s << std::endl;
std::cout << /*"S is obtainable? " << */ ((all.find(s) == all.end()) ? "No" : "Yes") << std::endl;
}
//ter a{ "1010" };
//ter b{ "2010" };
//std::cout << (a * 2).seq << std::endl;
//std::cout << (a + b).seq << std::endl;
return 0;
}
# | 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... |