답안 #398191

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
398191 2021-05-03T22:07:11 Z 4fecta Ancient Machine (JOI21_ancient_machine) C++17
0 / 100
82 ms 9052 KB
#include "Anna.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pii pair<int, int>
#define f first
#define s second
#define boost() cin.tie(0), cin.sync_with_stdio(0)

void Anna(int N, vector<char> S) {
    for (char c : S) {
        if (c == 'X') Send(0), Send(0);
        else if (c == 'Y') Send(0), Send(1);
        else Send(1), Send(0);
    }
}
#include "Bruno.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pii pair<int, int>
#define f first
#define s second
#define boost() cin.tie(0), cin.sync_with_stdio(0)

const int MN = 200005;

int n;
char a[MN];

void Bruno(int N, int L, vector<int> A) {
    assert(L == 2 * N);
    n = N;
    for (int i = 0; i < N; i++) {
        if (!A[i * 2] && !A[i * 2 + 1]) a[i] = 'X';
        else if (!A[i * 2]) a[i] = 'Y';
        else a[i] = 'Z';
    }
    stack<pii> s; //type, index
    for (int i = 0; i < n; i++) {
        if (a[i] == 'X') s.push({0, i});
        else if (a[i] == 'Y') {
            while (s.size() && s.top().f) Remove(s.top().s), s.pop();
            if (s.empty()) Remove(i);
            else s.push({1, i});
        } else {
            while (s.size() && s.top().f != 1) Remove(s.top().s), s.pop();
            if (s.size()) Remove(s.top().s), s.pop(), Remove(s.top().s), s.pop();
            Remove(i);
        }
    }
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 612 KB Wrong Answer [5]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 82 ms 9052 KB Wrong Answer [5]
2 Halted 0 ms 0 KB -