Submission #1294641

#TimeUsernameProblemLanguageResultExecution timeMemory
1294641NValchanovAncient Machine (JOI21_ancient_machine)C++20
70 / 100
43 ms6884 KiB
#include "Anna.h"
#include <vector>

void Anna(int n, std::vector<char> s) 
{
    bool found = false;
    for(int i = 0; i < n; i++)
    {
        if(s[i] == 'X')
        {
            if(!found)
            {
                Send(1);
                found = true;
            }
            else
            {
                Send(0);
            }
        }
        else if(s[i] == 'Y')
        {
            Send(0);
        }
        else 
        {
            if(found)
            {
                Send(1);
            }
            else
            {
                Send(0);
            }
        }
    }
}
#include "Bruno.h"
#include <vector>
#include <stack>
#include <cassert>
#include <iostream>

using namespace std;

const int MAXN = 1e5 + 10;

int type[MAXN];

void Bruno(int n, int l, std::vector<int> a) 
{
    assert(n == l);

    int first = -1;

    for(int i = 0; i < l; i++)
    {
        type[i] = a[i];

        if(first == -1 && type[i])
            first = i;
    }

    if(first == -1)
    {
        for(int i = 0; i < n; i++)
        {
            Remove(i);
        }

        return;
    }

    for(int i = 0; i < first; i++)
    {
        Remove(i);
    }

    stack < int > st;

    st.push(first);

    for(int i = first + 1; i < n; i++)
    {
        if(type[i] == 1)
        {
            while(st.size() >= 2)
            {
                int p = st.top();
                st.pop();

                Remove(p);
            }

            Remove(i);
        }
        else
        {
            st.push(i);
        }
    }

    while(!st.empty())
    {
        int p = st.top();
        st.pop();

        Remove(p);
    }
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...