Submission #1071041

#TimeUsernameProblemLanguageResultExecution timeMemory
107104112345678Ancient Machine (JOI21_ancient_machine)C++17
30 / 100
71 ms9660 KiB
#include "Anna.h"
#include <bits/stdc++.h>

using namespace std;

void Anna(int N, std::vector<char> S) {
    for (int i=0; i<N; i++)
    {
        if (S[i]=='X') Send(0), Send(0);
        if (S[i]=='Y') Send(0), Send(1);
        if (S[i]=='Z') Send(1), Send(0);
    }
}
#include "Bruno.h"
#include <bits/stdc++.h>

using namespace std;

const int nx=1e5+5;

int t[nx], curx=-1;

void Bruno(int N, int L, std::vector<int> A) {
    for (int i = 0; i < N; i++) t[i]=A[2*i]*2+A[2*i+1];
    stack<pair<int, int>> s;
    for (int i=0; i<N; i++)
    {
        if (t[i]==0)
        {
            if (curx==-1) curx=i;
            else Remove(i);
        }
        if (t[i]==1)
        {
            //cout<<"curx "<<curx<<'\n';
            if (curx!=-1) s.push({curx, i}), curx=-1;
            else Remove(i);
        }
        if (t[i]==2)
        {
            if (!s.empty())
            {
                if (curx!=-1) Remove(curx);
                while (!s.empty())
                {
                    Remove(s.top().second);
                    if (s.size()==1) curx=s.top().first;
                    else Remove(s.top().first);
                    s.pop();
                }
            }
            Remove(i);
        }
    }
    if (curx!=-1) Remove(curx);
    while (!s.empty()) Remove(s.top().first), Remove(s.top().second), s.pop();
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...