# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1109240 | SalihSahin | Crossing (JOI21_crossing) | C++14 | 7052 ms | 5644 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 <bits/stdc++.h>
#define pb push_back
#define int long long
using namespace std;
const int mod = 998244353;
const int inf = 1e9 + 20;
const int N = 1e5+5;
string op(string a, string b){
string res = "";
for(int i = 0; i < a.size(); i++){
if(a[i] == b[i]) res += a[i];
else{
if(a[i] == 'J'){
if(b[i] == 'O') res += 'I';
else res += 'O';
}
else if(a[i] == 'O'){
if(b[i] == 'J') res += 'I';
else res += 'J';
}
else{
if(b[i] == 'O') res += 'J';
else res += 'O';
}
}
}
return res;
}
int32_t main(){
cin.tie(0); cout.tie(0);
ios_base::sync_with_stdio(false);
int n;
cin>>n;
vector<string> v;
set<string> vis;
for(int i = 0; i < 3; i++){
string s;
cin>>s;
if(vis.find(s) != vis.end()) continue;
vis.insert(s);
v.pb(s);
}
if(v.size() > 1){
sort(v.begin(), v.end());
do{
string p1 = op(v[0], v[1]);
if(vis.find(p1) == vis.end()){
vis.insert(p1);
}
if(v.size() >= 3){
string p2 = op(p1, v[2]);
if(vis.find(p2) == vis.end()){
vis.insert(p2);
}
}
}
while(next_permutation(v.begin(), v.end()));
}
vector<string> can;
for(auto itr: vis){
can.pb(itr);
}
int q;
cin>>q;
string check;
cin>>check;
bool ok = 0;
for(auto itr: can){
if(itr == check) ok = 1;
}
if(ok) cout<<"Yes"<<endl;
else cout<<"No"<<endl;
int l, r;
char c;
while(q--){
cin>>l>>r>>c;
l--, r--;
ok = 0;
for(int i = l; i <= r; i++){
check[i] = c;
}
for(auto itr: can){
if(itr == check) ok = 1;
}
if(ok) cout<<"Yes"<<endl;
else cout<<"No"<<endl;
}
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... |