Submission #1071122

#TimeUsernameProblemLanguageResultExecution timeMemory
107112212345678Ancient Machine (JOI21_ancient_machine)C++17
40 / 100
61 ms9892 KiB
#include "Anna.h"
#include <bits/stdc++.h>

using namespace std;

void Anna(int N, std::vector<char> S) {
    while ((S.size()%5)!=0) S.push_back('X');
    vector<int> pw(10);
    pw[0]=1;
    for (int i=1; i<10; i++) pw[i]=pw[i-1]*3;
    for (int i=0; i<S.size(); i+=5)
    {
        int tmp=0;
        for (int j=0; j<5; j++) tmp+=(S[i+j]-'X')*pw[j];
        for (int j=0; j<8; j++) Send(((tmp&(1<<j))>0));
    }
}
#include "Bruno.h"
#include <bits/stdc++.h>

using namespace std;

const int nx=1e5+5;

int t[nx+20], curx=-1, cnt=0;

void Bruno(int N, int L, std::vector<int> A) {
    for (int i=0; i<L; i+=8)
    {
        int tmp=0;
        for (int j=0; j<8; j++) if (A[i+j]) tmp+=(1<<j);
        for (int j=0; j<5; j++) t[cnt++]=tmp%3, tmp/=3;
    }
    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)
        {
            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();
}

Compilation message (stderr)

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