Submission #945935

# Submission time Handle Problem Language Result Execution time Memory
945935 2024-03-14T08:53:56 Z beepbeepsheep Ancient Machine (JOI21_ancient_machine) C++17
0 / 100
68 ms 10492 KB
#include "Anna.h"
#include <vector>

void Anna(int N, std::vector<char> S) {
    for (auto u:S){
        if (u=='X') Send(0),Send(0);
        if (u=='Y') Send(0),Send(1);
        if (u=='Z') Send(1),Send(0);
    }
}
#include "Bruno.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
void Bruno(int N, int L, std::vector<int> A) {
    vector<char> v;
    for (int i=0;i<2*N;i+=2){
        ll res=A[i]*2+A[i+1];
        if (res==0) v.emplace_back('X');
        if (res==1) v.emplace_back('Y');
        if (res==2) v.emplace_back('Z');
    }
    stack<pair<ll,char>> s;
    ll cnty=0;
    vector<ll> out;
    for (int i=0;i<N;i++){
        if (v[i]=='X') s.emplace(i,'X');
        if (v[i]=='Y'){
            if (s.size() && s.top().second=='X')
                s.emplace(i,'Y'),cnty++;
            else out.emplace_back(i);
        }
        if (v[i]=='Z'){
            if (cnty==0) out.emplace_back(i);
            else{
                char c; ll idx;
                while (s.top().second!='Y'){
                    tie(idx,c)=s.top();
                    out.emplace_back(idx);
                    s.pop();
                }
                ll xidx,yidx;
                yidx=s.top().first;
                s.pop();
                xidx=s.top().first;
                s.pop();
                out.emplace_back(yidx);
                out.emplace_back(xidx);
                out.emplace_back(i);
                cnty--;
            }
        }
    }
    while (s.size()){
        out.emplace_back(s.top().first);
        s.pop();
    }
    for (auto u:out) Remove(u);
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 780 KB Output is correct
2 Correct 0 ms 796 KB Output is correct
3 Correct 1 ms 796 KB Output is correct
4 Correct 0 ms 780 KB Output is correct
5 Incorrect 0 ms 784 KB Wrong Answer [6]
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 68 ms 10492 KB Wrong Answer [6]
2 Halted 0 ms 0 KB -