답안 #935502

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
935502 2024-02-29T08:19:23 Z wii Ancient Machine (JOI21_ancient_machine) C++17
30 / 100
66 ms 9744 KB
#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();
    }
}

Compilation message

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) {
      |                     ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 776 KB Output is correct
2 Correct 0 ms 780 KB Output is correct
3 Correct 0 ms 780 KB Output is correct
4 Correct 0 ms 780 KB Output is correct
5 Correct 0 ms 856 KB Output is correct
6 Correct 0 ms 780 KB Output is correct
7 Correct 0 ms 776 KB Output is correct
8 Correct 0 ms 780 KB Output is correct
9 Correct 0 ms 780 KB Output is correct
10 Correct 0 ms 780 KB Output is correct
11 Correct 0 ms 784 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Partially correct 57 ms 9124 KB Partially correct
2 Partially correct 57 ms 9272 KB Partially correct
3 Partially correct 57 ms 9288 KB Partially correct
4 Partially correct 57 ms 9276 KB Partially correct
5 Partially correct 57 ms 9436 KB Partially correct
6 Partially correct 57 ms 9300 KB Partially correct
7 Partially correct 57 ms 9280 KB Partially correct
8 Partially correct 64 ms 9276 KB Partially correct
9 Partially correct 59 ms 9288 KB Partially correct
10 Partially correct 57 ms 9280 KB Partially correct
11 Partially correct 57 ms 9264 KB Partially correct
12 Partially correct 59 ms 9296 KB Partially correct
13 Partially correct 63 ms 9296 KB Partially correct
14 Partially correct 55 ms 9256 KB Partially correct
15 Partially correct 54 ms 9292 KB Partially correct
16 Partially correct 55 ms 9280 KB Partially correct
17 Partially correct 62 ms 9128 KB Partially correct
18 Partially correct 62 ms 9248 KB Partially correct
19 Partially correct 55 ms 9344 KB Partially correct
20 Partially correct 55 ms 9304 KB Partially correct
21 Partially correct 56 ms 9744 KB Partially correct
22 Partially correct 61 ms 9288 KB Partially correct
23 Partially correct 56 ms 9436 KB Partially correct
24 Partially correct 56 ms 9292 KB Partially correct
25 Partially correct 64 ms 9136 KB Partially correct
26 Partially correct 62 ms 9272 KB Partially correct
27 Partially correct 62 ms 9112 KB Partially correct
28 Partially correct 64 ms 9304 KB Partially correct
29 Partially correct 61 ms 9324 KB Partially correct
30 Partially correct 66 ms 9696 KB Partially correct
31 Partially correct 63 ms 9272 KB Partially correct
32 Partially correct 57 ms 9256 KB Partially correct
33 Partially correct 57 ms 9312 KB Partially correct