답안 #1072364

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1072364 2024-08-23T17:32:39 Z mickey080929 Ancient Machine (JOI21_ancient_machine) C++17
0 / 100
10 ms 2840 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<=16; i++) {
        Send(bool(x & (1<<i)));
    }
    for (int i=0; i<=16; i++) {
        Send(bool(z & (1<<i)));
    }
    cout << x << ' ' << z << '\n';
    vector<int> A;
    for (int i=x; i<z; i++) {
        if (S[i] == 'X') {
            A.push_back(1);
            i ++;
        }
        else {
            A.push_back(0);
        }
    }
    mySend(A);
}
#include "Bruno.h"
#include <bits/stdc++.h>

using namespace std;

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<=16; i++) {
        if (A[i] == 1) {
            x ^= (1<<i);
        }
    }
    for (int i=0; i<=16; i++) {
        if (A[i+17] == 1) {
            z ^= (1<<i);
        }
    }
    vector<int> v;
    for (int i=34; i<L; i++) {
        if (A[i]) {
            v.push_back(1);
            v.push_back(0);
        }
        else {
            v.push_back(0);
        }
    }
    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);
        }
    }
    assert(idx[0] == x);
    assert(idx.back() == z);
    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:34:21: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   34 |     while (v.size() > z - x) v.pop_back();
      |            ~~~~~~~~~^~~~~~~
Bruno.cpp:37:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |     for (int i=0; i<v.size(); i++) {
      |                   ~^~~~~~~~~
Bruno.cpp:53:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   53 |     for (int i=0; i+1<idx.size(); i++) {
      |                   ~~~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 792 KB Do not print anything to standard output!!
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 10 ms 2840 KB Do not print anything to standard output!!
2 Halted 0 ms 0 KB -