Submission #1071613

# Submission time Handle Problem Language Result Execution time Memory
1071613 2024-08-23T09:22:20 Z 정민찬(#11138) Ancient Machine (JOI21_ancient_machine) C++17
0 / 100
38 ms 8036 KB
#include "Anna.h"
#include <bits/stdc++.h>

using namespace std;

void Send(int a);
void Remove(int d);

void mySend(vector<int> v) {
    for (auto &x : v) {
        Send(x);
    }
}

void Anna(int N, vector<char> S) {
    int x = -1, z = -1;
    for (int i=0; i<N; i++) {
        if (S[i] == 'X') {
            x = i;
            break;
        }
    }
    for (int i=N-1; i>=0; i--) {
        if (S[i] == 'Z') {
            z = i;
            break;
        }
    }
    if (x == -1 || z == -1 || x > z) {
        return;
    }
    for (int i=0; i<=13; i++) {
        Send(bool(x & (1<<i)));
    }
    for (int i=0; i<=13; i++) {
        Send(bool(z & (1<<i)));
    }
    vector<int> A;
    for (int i=x; i<z; i++) {
        if (S[i] == 'X') {
            if (!A.empty()) A.pop_back();
            A.push_back(1);
            i ++;
        }
        else {
            A.push_back(0);
        }
    }
    mySend(A);
}
#include "Bruno.h"
#include <bits/stdc++.h>

using namespace std;

void Send(int a);
void Remove(int d);

void Bruno(int N, int L, vector<int> A) {
    if (L == 0) {
        for (int i=0; i<N; i++) {
            Remove(i);
        }
        return;
    }
    int x = 0, z = 0;
    for (int i=0; i<=13; i++) {
        if (A[i] == 1) {
            x ^= (1<<i);
        }
    }
    for (int i=0; i<=13; i++) {
        if (A[i+14] == 1) {
            z ^= (1<<i);
        }
    }
    vector<int> v;
    for (int i=28; i<L; i++) {
        if (A[i]) {
            v.push_back(0);
            v.push_back(1);
            v.push_back(0);
        }
        else {
            v.push_back(0);
        }
    }
    v.erase(v.begin());
    while (v.size() > z - x) v.pop_back();
    v.push_back(1);
    vector<int> idx;
    for (int i=0; i<v.size(); i++) {
        if (v[i]) {
            idx.push_back(i + x);
        }
    }
    vector<int> chk(N, 0);
    for (int i=0; i<idx[0]; i++) {
        Remove(i);
        chk[i] = 1;
    }
    for (int i=idx.back()+1; i<N; i++) {
        Remove(i);
        chk[i] = 1;
    }
    for (int i=0; i+1<idx.size(); i++) {
        for (int j=idx[i]+1; j<=idx[i+1]-2; j++) {
            Remove(j);
            chk[j] = 1;
        }
    }
    for (int i=idx.back()-1; i>=idx[0]; i--) {
        if (!chk[i]) {
            Remove(i);
        }
    }
    Remove(idx.back());
}

Compilation message

Bruno.cpp: In function 'void Bruno(int, int, std::vector<int>)':
Bruno.cpp:39:21: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   39 |     while (v.size() > z - x) v.pop_back();
      |            ~~~~~~~~~^~~~~~~
Bruno.cpp:42:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |     for (int i=0; i<v.size(); i++) {
      |                   ~^~~~~~~~~
Bruno.cpp:56:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   56 |     for (int i=0; i+1<idx.size(); i++) {
      |                   ~~~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 792 KB Wrong Answer [6]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 38 ms 8036 KB Wrong Answer [6]
2 Halted 0 ms 0 KB -