# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
523080 | amunduzbaev | Ancient Machine (JOI21_ancient_machine) | C++17 | 0 ms | 0 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 "Anna.h"
#include "bits/stdc++.h"
using namespace std;
#define ar array
void Anna(int n, vector<char> s) {
vector<int> res(n);
ar<int, 3> last {n, n, n};
vector<ar<int, 3>> par(n + 1); par[n] = last;
for(int i=n-1;~i;i--){
last[s[i] - 'X'] = i;
par[i] = last;
}
int i = par[0][0];
if(i < n){
int j = i; res[i] = 1;
while(j < n){
j = par[j][1];
int l = par[j][2];
if(l < n){
res[j] = res[l] = 1;
} j = l;
}
}
//~ for(int i=0;i<n;i++) cout<<res[i]<<" ";
//~ cout<<endl;
for(int i=0;i<n;i++){
Send(res[i]);
}
}