# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1071166 | thinknoexit | Ancient Machine (JOI21_ancient_machine) | C++17 | 49 ms | 9792 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;
using ll = long long;
namespace {
int n;
}
void Anna(int N, vector<char> S) {
n = N;
for (int i = 0;i < n;i++) {
int v = S[i] - 'X';
Send(!!(v & 1));
Send(!!(v & 2));
}
}
#include "Bruno.h"
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
namespace {
int n;
int a[100100], pos[100100];
bool ch[100100];
} // namespace
void Bruno(int N, int L, vector<int> A) {
n = N;
for (int i = 0;i < n;i++) {
a[i] = A[2 * i] + 2 * A[2 * i + 1];
}
stack<int> st;
for (int i = 0;i < n;i++) {
pos[i] = -1;
if (a[i] == 2) continue;
if (a[i] == 0) st.push(i);
else {
if (st.empty()) Remove(i);
else {
pos[i] = st.top();
st.pop();
}
}
}
while (!st.empty()) {
Remove(st.top());
st.pop();
}
for (int i = 0;i < n;i++) {
if (pos[i] != -1) {
while (!st.empty() && pos[st.top()] > pos[i]) {
Remove(st.top());
Remove(pos[st.top()]);
st.pop();
}
st.push(i);
continue;
}
if (a[i] == 0 || a[i] == 1) continue;
if (!st.empty()) {
Remove(st.top());
Remove(pos[st.top()]);
st.pop();
}
Remove(i);
}
while (!st.empty()) {
Remove(st.top());
Remove(pos[st.top()]);
st.pop();
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |