Submission #712606

# Submission time Handle Problem Language Result Execution time Memory
712606 2023-03-19T09:46:38 Z hoainiem Ancient Machine (JOI21_ancient_machine) C++17
0 / 100
67 ms 9156 KB
#include "Anna.h"
#include<bits/stdc++.h>
using namespace std;
namespace {

int variable_example = 0;

}

void Anna(int N, std::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;
namespace {

int variable_example = 0;

int FunctionExample(int P) { return 1 - P; }

}  // namespace

void Bruno(int N, int L, std::vector<int> A) {
    string s;
    for (int i = 0, j = 0; i < N; i++, j += 2){
        if (A[j] == 0){
            if (A[j + 1] == 0)
                s.push_back('x');
            else
                s.push_back('y');
        }
        else
            s.push_back('z');
    }
    int l = 0, ptr, r = N - 1;
    while (l < N && s[l] != 'x')
        Remove(l++);
    if (l == N)
        return;
    while (r >= l && s[r] != 'z')
        Remove(r--);
    if (l > r)
        return;
    stack<int>pq;
    pq.push(l);
    ptr = l + 1;
    while (ptr <= r){
        if (ptr == r){
            Remove(pq.top());
            pq.pop();
            while (!pq.empty()){
                Remove(pq.top());
                pq.pop();
                Remove(pq.top());
                pq.pop();
            }
            Remove(ptr);
            break;
        }
        char ch = s[ptr];
        while (s[ptr] != 'y')
            Remove(ptr++);
        if (ptr > r){
            while (!pq.empty()){
                Remove(pq.top());
                pq.pop();
            }
            return;
        }
        pq.push(ptr++);
        while (s[ptr] == 'y')
            Remove(ptr++);
        if (s[ptr] == 'x')
            pq.push(ptr++);
        else{
            while (pq.size() > 1){
                Remove(pq.top());
                pq.pop();
                Remove(pq.top());
                pq.pop();
            }
        }
    }
}

Compilation message

Anna.cpp:6:5: warning: '{anonymous}::variable_example' defined but not used [-Wunused-variable]
    6 | int variable_example = 0;
      |     ^~~~~~~~~~~~~~~~

Bruno.cpp: In function 'void Bruno(int, int, std::vector<int>)':
Bruno.cpp:49:14: warning: unused variable 'ch' [-Wunused-variable]
   49 |         char ch = s[ptr];
      |              ^~
Bruno.cpp: At global scope:
Bruno.cpp:8:5: warning: 'int {anonymous}::FunctionExample(int)' defined but not used [-Wunused-function]
    8 | int FunctionExample(int P) { return 1 - P; }
      |     ^~~~~~~~~~~~~~~
Bruno.cpp:6:5: warning: '{anonymous}::variable_example' defined but not used [-Wunused-variable]
    6 | int variable_example = 0;
      |     ^~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 648 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 67 ms 9156 KB Wrong Answer [6]
2 Halted 0 ms 0 KB -