# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
710702 | Ronin13 | Crossing (JOI21_crossing) | C++14 | 7014 ms | 92152 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 ll long long
#define ull unsigned ll
#define f first
#define s second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define epb emplace_back
using namespace std;
const int nmax = 1000001;
map <vector <int> , bool> used;
vector <vector <int> > vec;
vector <int> op(vector <int> &a, vector <int> &b){
vector <int> ans;
for(int i = 0; i < a.size(); i++){
int x = a[i] + b[i];
x = -x;
x %= 3;
x += 3;
x %= 3;
ans.pb(x);
}
return ans;
}
void rec(vector <int> v){
used[v] = true;
for(auto to : vec){
vector <int> x = op(to, v);
if(used[x]) continue;
rec(x);
}
}
int main(){
ios_base::sync_with_stdio(false); cin.tie(0);
int n; cin >> n;
string a[3];
for(int i = 0; i < 3; i++){
vector<int> v;
cin >> a[i];
for(int j = 0; j < n; j++){
if(a[i][j] == 'O')
v.pb(0);
if(a[i][j] == 'J')
v.pb(1);
if(a[i][j] == 'I')
v.pb(2);
}
used[v] = true;
vec.pb(v);
}
for(int i = 0; i < 3; i++)
rec(vec[i]);
int q; cin >> q;
vector <int> t;
for(int i = 0; i < n; i++){
char c; cin >> c;
if(c == 'J')
t.pb(1);
if(c == 'O')
t.pb(0);
if(c == 'I')
t.pb(2);
}
if(used[t]) cout << "Yes\n";
else cout << "No\n";
while(q--){
int l,r; cin >> l >> r;
char c; cin >> c;
int x;
if(c == 'O')
x = 0;
if(c == 'J')
x = 1;
if(c == 'I')
x = 2;
if(n <= 100)
for(int i = l - 1; i < r; i++)
t[i] = x;
used[t] ? cout << "Yes\n" : cout << "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... |