# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
523080 | 2022-02-07T02:37:21 Z | amunduzbaev | Ancient Machine (JOI21_ancient_machine) | C++17 | 0 ms | 0 KB |
#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]); } }