Submission #996378

#TimeUsernameProblemLanguageResultExecution timeMemory
996378hotboy2703Ancient Machine (JOI21_ancient_machine)C++17
30 / 100
66 ms11468 KiB
#include "Anna.h"

#include<bits/stdc++.h>
using ll = int;
using namespace std;
#define pll pair <ll,ll>
#define fi first
#define se second
#define MP make_pair
#define sz(a) (ll((a).size()))
#define BIT(mask,i) (((mask) >> (i))&1)
#define MASK(i) (1LL << (i))

namespace A{

}

void Anna(int N, std::vector<char> S) {
    using namespace A;
    for (ll i = 0;i < N;i ++){
        Send(BIT(S[i] - 'X',0));
        Send(BIT(S[i] - 'X',1));
    }
}
#include "Bruno.h"

#include<bits/stdc++.h>
using ll = int;
using namespace std;
#define pll pair <ll,ll>
#define fi first
#define se second
#define MP make_pair
#define sz(a) (ll((a).size()))
#define BIT(mask,i) (((mask) >> (i))&1)
#define MASK(i) (1LL << (i))

namespace B{
    struct pt{
        ll type,l,r;
    };
    void del(pt x){
        for (ll i = x.l;i <= x.r;i ++)Remove(i);
    }
}  // namespace

void Bruno(int N, int L, std::vector<int> A) {
    using namespace B;
    vector <ll> a;
    for (ll i = 0;i < N;i ++){
        a.push_back(A[i*2] + A[i*2+1] * 2);
    }
    vector <pt> nw;
    for (ll i = 0;i < N;i ++){
        ll j = i;
        while (j + 1 < N && a[j+1] == a[i])j++;
        nw.push_back({a[i],i,j});
        i = j;
    }
    while (!nw.empty() && nw.back().type != 2){
        del(nw.back());
        nw.pop_back();
    }
    ll last0 = -1;
    for (ll i = 0;i < sz(nw);i ++){
        if (last0 == -1){
            if (nw[i].type == 0)last0 = i;
            else{
                del(nw[i]);
            }
        }
        else{
            ll j = i;
            while (nw[j].type != 2)j++;
            for (ll k = j - 1;k >= i;k --){
                del(nw[k]);
            }
            del(nw[j]);
            i = j;
        }
    }
    if (last0 != -1)del(nw[last0]);
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...