# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
715207 | duchuy297 | 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 <vector>
namespace {
int variable_example = 0;
}
void Anna(int N, std::vector<char> S) {
for (auto u : S) {
if (u == 'X') send (0), send (0);
else if (u == 'Y') send (0), send(1);
else send (1), send(0);
}
}
#include "Bruno.h"
#include <vector>
namespace {
int variable_example = 0;
int FunctionExample(int P) { return 1 - P; }
} // namespace
void Bruno(int N, int L, std::vector<int> A) {
string s;
int n = N;
for (int i=0; i<2*n; i+=2) {
if (s[i] == 0 && s[i+1] == 0) s.push_back('X');
else if (s[i] == 0 && s[i+1] == 1) s.push_back('Y');
else s.push_back('Z');
}
int l = -1, r = -1;
for (int i=0; i<n; i++) {
if (s[i] == 'X') {
l = i;
break;
}
}
for (int i=n-1; i>=0; i--) {
if (s[i] == 'Z') {
r = i;
break;
}
}
if (l == -1 || r == -1) {
for (int i=0; i<n; i++) remove(i);
return;
}
for (int i=0; i<l; i++) remove(i);
for (int i=r+1; i<n; i++) remove(i);
stack<int> st;
st.push(l);
for (int i=l+1; i<=r; i++) {
int u = st.top();
if (s[i] == s[u]) {
remove(i);
continue;
}
if (s[i] == 'Z') {
while (st.size() > 1) {
int u = st.top();
remove(u);
st.pop();
}
}
else st.push(i);
}
while (st.size()) {
int u = st.top();
remove(u);
st.pop();
}
}