Submission #709639

# Submission time Handle Problem Language Result Execution time Memory
709639 2023-03-14T04:45:03 Z lmqzzz Ancient Machine (JOI21_ancient_machine) C++17
30 / 100
92 ms 9332 KB
#include "Anna.h"

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

void Anna(int N, std::vector<char> S) {
        for (int i = 0; i < N; i++) {
                if (S[i] == 'X') Send(0), Send(0);
                if (S[i] == 'Y') Send(0), Send(1);
                if (S[i] == 'Z') Send(1), Send(1);
        }
}
#include "Bruno.h"

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

void Bruno(int N, int L, std::vector<int> A) {
        string s = "";
        for (int i = 0; i < L; i += 2) {
                if (A[i] + A[i + 1] == 0) s += 'X';
                if (A[i] + A[i + 1] == 1) s += 'Y';
                if (A[i] + A[i + 1] == 2) s += 'Z';
        }
        int firstX = s.size();
        for (int i = 0; i < s.size(); i++) {
                if (s[i] == 'X') {
                        firstX = i;
                        break;
                }
        }
        int lastZ = firstX;
        for (int i = s.size() - 1; i > firstX; i--) {
                if (s[i] == 'Z') {
                        lastZ = i;
                        break;
                }
        }
        for (int i = 0; i < firstX; i++) Remove(i);
        for (int i = s.size() - 1; i > lastZ; i--) Remove(i);
        stack<int> st;
        if (firstX < N) st.push(firstX);
        for (int i = firstX + 1; i <= lastZ; i++) {
                if (s[st.top()] == 'X') {
                        if (s[i] == 'X') Remove(i);
                        if (s[i] == 'Y') st.push(i);
                        if (s[i] == 'Z') {
                                while (st.size() > 1) Remove(st.top()), st.pop();
                                Remove(i);
                        }
                } else if (s[st.top()] == 'Y') {
                        if (s[i] == 'X') st.push(i);
                        if (s[i] == 'Y') Remove(i);
                        if (s[i] == 'Z') {
                                while (st.size() > 1) Remove(st.top()), st.pop();
                                Remove(i);
                        }
                } else {
                        assert(0);
                }
        }
        while (st.size()) Remove(st.top()), st.pop();
}

Compilation message

Bruno.cpp: In function 'void Bruno(int, int, std::vector<int>)':
Bruno.cpp:14:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   14 |         for (int i = 0; i < s.size(); i++) {
      |                         ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 508 KB Output is correct
2 Correct 0 ms 516 KB Output is correct
3 Correct 0 ms 512 KB Output is correct
4 Correct 0 ms 516 KB Output is correct
5 Correct 0 ms 508 KB Output is correct
6 Correct 0 ms 516 KB Output is correct
7 Correct 0 ms 508 KB Output is correct
8 Correct 0 ms 516 KB Output is correct
9 Correct 1 ms 516 KB Output is correct
10 Correct 0 ms 508 KB Output is correct
11 Correct 0 ms 508 KB Output is correct
# Verdict Execution time Memory Grader output
1 Partially correct 69 ms 9196 KB Partially correct
2 Partially correct 69 ms 9056 KB Partially correct
3 Partially correct 67 ms 9136 KB Partially correct
4 Partially correct 69 ms 9124 KB Partially correct
5 Partially correct 67 ms 9100 KB Partially correct
6 Partially correct 71 ms 9120 KB Partially correct
7 Partially correct 68 ms 9192 KB Partially correct
8 Partially correct 66 ms 9112 KB Partially correct
9 Partially correct 67 ms 9128 KB Partially correct
10 Partially correct 65 ms 9192 KB Partially correct
11 Partially correct 69 ms 9292 KB Partially correct
12 Partially correct 68 ms 9128 KB Partially correct
13 Partially correct 85 ms 9112 KB Partially correct
14 Partially correct 72 ms 9120 KB Partially correct
15 Partially correct 74 ms 9128 KB Partially correct
16 Partially correct 68 ms 9132 KB Partially correct
17 Partially correct 78 ms 9152 KB Partially correct
18 Partially correct 75 ms 9196 KB Partially correct
19 Partially correct 71 ms 9080 KB Partially correct
20 Partially correct 76 ms 9200 KB Partially correct
21 Partially correct 70 ms 9200 KB Partially correct
22 Partially correct 74 ms 9208 KB Partially correct
23 Partially correct 68 ms 9228 KB Partially correct
24 Partially correct 65 ms 9332 KB Partially correct
25 Partially correct 74 ms 9128 KB Partially correct
26 Partially correct 81 ms 9148 KB Partially correct
27 Partially correct 92 ms 9196 KB Partially correct
28 Partially correct 76 ms 9136 KB Partially correct
29 Partially correct 75 ms 9124 KB Partially correct
30 Partially correct 81 ms 9064 KB Partially correct
31 Partially correct 73 ms 9180 KB Partially correct
32 Partially correct 69 ms 9168 KB Partially correct
33 Partially correct 68 ms 9096 KB Partially correct