제출 #935502

#제출 시각아이디문제언어결과실행 시간메모리
935502wiiAncient Machine (JOI21_ancient_machine)C++17
30 / 100
66 ms9744 KiB
#include <vector>
using namespace std;

void Anna(int N, std::vector<char> S);
void Send(int a);

void Anna(int N, std::vector<char> S) {
    for (auto &x: S) {
        if (x == 'X') Send(0), Send(0);
        if (x == 'Y') Send(0), Send(1);
        if (x == 'Z') Send(1), Send(1);
    }
}
#include <deque>

#include <vector>
#include <iostream>
using namespace std;

void Bruno(int N, int L, std::vector<int> A);
void Remove(int d);

// 11 XYZXZYXYXYZ

void Bruno(int N, int L, std::vector<int> A) {
    vector<char> S;
    for (int i = 0; i < A.size(); i += 2) {
        if (A[i] + A[i + 1] == 0) S.push_back('X');
        if (A[i] + A[i + 1] == 1) S.push_back('Y');
        if (A[i] + A[i + 1] == 2) S.push_back('Z');
    }

    deque<int> d;
    for (int i = N - 1; i >= 0; --i) {
        if (d.empty()) {
            if (S[i] == 'Z') d.push_back(i); else Remove(i);
        } else {
            if (S[i] == 'Y') {
                if (S[d.front()] == 'Z')
                    d.push_front(i);
                else Remove(i);
            } else if (S[i] == 'X') {
                while (d.size() >= 2) {
                    while (d.size() > 1 && S[d.front() == 'Z']) {
                        Remove(d.front()); d.pop_front();
                    }

                    if (S[d[0]] == 'Y' && S[d[1]] == 'Z') {
                        Remove(d[0]); d.pop_front();
                        if (d.size() > 1) Remove(d[0]), d.pop_front();
                    } else break;
                } Remove(i);
            } else d.push_front(i);
        }
    }

    while (!d.empty()) {
        Remove(d[0]); d.pop_front();
    }
}

컴파일 시 표준 에러 (stderr) 메시지

Bruno.cpp: In function 'void Bruno(int, int, std::vector<int>)':
Bruno.cpp:14:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   14 |     for (int i = 0; i < A.size(); i += 2) {
      |                     ~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...