# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
712667 | hoainiem | Ancient Machine (JOI21_ancient_machine) | C++17 | 70 ms | 9156 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;
namespace {
int variable_example = 0;
}
void Anna(int N, std::vector<char> S) {
for (char c : S)
if (c == 'X'){
Send(0);
Send(0);
}
else{
if (c == 'Y'){
Send(0);
Send(1);
}
else{
Send(1);
Send(0);
}
}
}
#include "Bruno.h"
#include<bits/stdc++.h>
using namespace std;
namespace {
int variable_example = 0;
int FunctionExample(int P) { return 1 - P; }
} // namespace
string s;
stack<int>pq;
void Bruno(int N, int L, std::vector<int> A) {
for (int i = 0, j = 0; i < N; i++, j += 2){
if (A[j] == 0){
if (A[j + 1] == 0)
s.push_back('x');
else
s.push_back('y');
}
else
s.push_back('z');
}
int l = 0, ptr, r = N - 1;
while (l < N && s[l] != 'x')
Remove(l++);
if (l == N)
return;
while (r >= l && s[r] != 'z')
Remove(r--);
if (l > r)
return;
pq.push(l);
ptr = l + 1;
while (ptr <= r){
if (ptr == r){
if (s[pq.top()] == 'x'){
Remove(pq.top());
pq.pop();
}
while (!pq.empty()){
Remove(pq.top());
pq.pop();
}
Remove(ptr);
break;
}
if (s[ptr] == 'z'){
if (s[pq.top()] == 'x'){
Remove(pq.top());
pq.pop();
}
while (pq.size() > 1){
Remove(pq.top());
pq.pop();
if (pq.size() == 1)
continue;
Remove(pq.top());
pq.pop();
}
Remove(ptr++);
continue;
}
while (s[ptr] != 'y')
Remove(ptr++);
if (ptr > r){
while (!pq.empty()){
Remove(pq.top());
pq.pop();
}
return;
}
pq.push(ptr++);
while (s[ptr] == 'y')
Remove(ptr++);
if (s[ptr] == 'x')
pq.push(ptr++);
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |