Submission #930857

#TimeUsernameProblemLanguageResultExecution timeMemory
930857boris_mihovAncient Machine (JOI21_ancient_machine)C++17
0 / 100
42 ms7812 KiB
#include "Anna.h"
#include <vector>


void Anna(int N, std::vector <char> s) 
{
    bool foundX = false;
    for (int i = 0 ; i < N ; ++i)
    {
        if (!foundX && s[i] == 'X')
        {
            foundX = true;
            Send(1);
            i++;
        } else if (foundX && s[i] == 'Z')
        {
            Send(1);
            i++;
        } else
        {
            Send(0);
        }
    }
}
#include "Bruno.h"
#include <vector>

const int MAXN = 100000 + 10;

void Bruno(int N, int L, std::vector <int> A) 
{
    int xPos = -1;
    int added = 0;
    std::vector <int> pos;
    for (int i = 0 ; i < L ; ++i)
    {
        if (A[i] == 1)
        {
            if (xPos == -1) xPos = i;
            pos.push_back(i + added);
            added++;
        }
    }

    if (pos.empty())
    {
        for (int i = 0 ; i < N ; ++i)
        {
            Remove(i);
        }

        return;
    }

    if (pos.back() < N - 1) pos.push_back(N - 1);
    for (int i = 0 ; i < xPos ; ++i)
    {
        Remove(i);
    }

    for (int i = 1 ; i < pos.size() ; ++i)
    {
        for (int j = pos[i] - 1 ; j > pos[i - 1] ; --j)
        {
            Remove(j);
        }

        Remove(pos[i]);
    }

    Remove(pos[0]);
}

Compilation message (stderr)

Bruno.cpp: In function 'void Bruno(int, int, std::vector<int>)':
Bruno.cpp:37:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |     for (int i = 1 ; i < pos.size() ; ++i)
      |                      ~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...