답안 #945941

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
945941 2024-03-14T08:57:37 Z beepbeepsheep Ancient Machine (JOI21_ancient_machine) C++17
0 / 100
56 ms 10060 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'){
            char c; ll idx;
            while (cnty){
                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);
                cnty--;
            }
            out.emplace_back(i);
        }
    }
    while (s.size()){
        out.emplace_back(s.top().first);
        s.pop();
    }
    for (auto u:out) Remove(u);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 792 KB Output is correct
2 Correct 0 ms 792 KB Output is correct
3 Correct 0 ms 780 KB Output is correct
4 Correct 0 ms 792 KB Output is correct
5 Incorrect 0 ms 776 KB Wrong Answer [6]
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 56 ms 10060 KB Wrong Answer [6]
2 Halted 0 ms 0 KB -