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>
using namespace std;
char other( char a, char b ) {
if ( a != 'J' && b != 'J' )
return 'J';
if ( a != 'O' && b != 'O' )
return 'O';
return 'I';
}
string combine( string a, string b ) {
string ans;
ans.resize( a.size() );
for ( int i = 0; i < a.size(); i++ )
ans[i] = (a[i] == b[i] ? a[i] : other( a[i], b[i] ) );
return ans;
}
set<string> s;
int main() {
int n, q;
string s1, s2, s3, t;
cin >> n >> s1 >> s2 >> s3;
s.insert( s1 );
s.insert( s2 );
s.insert( s3 );
bool isNew = true;
while ( isNew ) {
isNew = false;
set<string> newS;
for ( string x: s ) {
string y1 = combine( x, s1 );
string y2 = combine( x, s2 );
string y3 = combine( x, s3 );
if ( s.find( y1 ) == s.end() && newS.find( y1 ) == newS.end() ) {
isNew = true;
newS.insert( y1 );
}
if ( s.find( y2 ) == s.end() && newS.find( y2 ) == newS.end() ) {
isNew = true;
newS.insert( y2 );
}
if ( s.find( y3 ) == s.end() && newS.find( y3 ) == newS.end() ) {
isNew = true;
newS.insert( y3 );
}
}
for ( string x: newS )
s.insert( x );
}
cin >> q >> t;
cout << ((s.find( t ) != s.end()) ? "Yes\n" : "No\n");
while ( q-- ) {
int l, r;
char ch;
cin >> l >> r >> ch;
l--;
r--;
for ( int i = l; i <= r; i++ )
t[i] = ch;
cout << ((s.find( t ) != s.end()) ? "Yes\n" : "No\n");
}
return 0;
}
Compilation message (stderr)
Main.cpp: In function 'std::string combine(std::string, std::string)':
Main.cpp:17:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
17 | for ( int i = 0; i < a.size(); i++ )
| ~~^~~~~~~~~~
# | 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... |