제출 #1325241

#제출 시각아이디문제언어결과실행 시간메모리
1325241miraiyaAncient Machine (JOI21_ancient_machine)C++20
70 / 100
59 ms6888 KiB
#include <bits/stdc++.h>
using namespace std;

void Send(int a);

void Anna(int N, vector<char> S) {
    bool fx = true;
    for (int i = 0; i < N; i++) {
        if (S[i] == 'X') { 
            Send(fx);
            fx = false;
        }
        if (S[i] == 'Y') {
            Send(0);
        }
        if (S[i] == 'Z') {
            Send(!fx);
        }
    }
}

#include <bits/stdc++.h>
using namespace std;

void Remove(int d);

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

    vector<bool> del(N, false);

    stack<int> st;
    for (int i = pos + 1; i < L; i++) {
        if (A[i] == 1) {
            while (st.size()) {
                Remove(st.top());
                del[st.top()] = true;
                st.pop();
            }
            Remove(i);
            del[i] = true;
        } else {
            st.push(i);
        }
    }
    for (int i = 0; i < L; i++) {
        if (!del[i]) {
            Remove(i);
        }
    }
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...