# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
945946 | beepbeepsheep | Ancient Machine (JOI21_ancient_machine) | C++17 | 74 ms | 10632 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>
void Anna(int N, std::vector<char> S) {
for (auto u:S){
if (u=='X') Send(0),Send(0);
if (u=='Y') Send(0),Send(1);
if (u=='Z') Send(1),Send(0);
}
}
#include "Bruno.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
void Bruno(int N, int L, std::vector<int> A) {
vector<char> v;
for (int i=0;i<2*N;i+=2){
ll res=A[i]*2+A[i+1];
if (res==0) v.emplace_back('X');
if (res==1) v.emplace_back('Y');
if (res==2) v.emplace_back('Z');
}
stack<pair<ll,char>> s;
ll cnty=0;
vector<ll> out;
for (int i=0;i<N;i++){
if (v[i]=='X') s.emplace(i,'X');
if (v[i]=='Y'){
if (s.size() && s.top().second=='X')
s.emplace(i,'Y'),cnty++;
else out.emplace_back(i);
}
if (v[i]=='Z'){
char c; ll idx;
while (cnty){
while (s.top().second!='Y'){
tie(idx,c)=s.top();
out.emplace_back(idx);
s.pop();
}
ll xidx,yidx;
yidx=s.top().first;
s.pop();
out.emplace_back(yidx);
cnty--;
if (cnty>0){
xidx=s.top().first;
s.pop();
out.emplace_back(xidx);
}
}
out.emplace_back(i);
}
}
while (s.size()){
out.emplace_back(s.top().first);
s.pop();
}
for (auto u:out) Remove(u);
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |