답안 #1071630

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1071630 2024-08-23T09:28:12 Z 정민찬(#11138) Ancient Machine (JOI21_ancient_machine) C++17
5 / 100
43 ms 9144 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') {
            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(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:37:21: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   37 |     while (v.size() > z - x) v.pop_back();
      |            ~~~~~~~~~^~~~~~~
Bruno.cpp:40:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |     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++) {
      |                   ~~~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 784 KB Output is correct
2 Correct 0 ms 796 KB Output is correct
3 Correct 0 ms 796 KB Output is correct
4 Correct 0 ms 788 KB Output is correct
5 Correct 0 ms 796 KB Output is correct
6 Correct 1 ms 784 KB Output is correct
7 Correct 0 ms 796 KB Output is correct
8 Correct 0 ms 784 KB Output is correct
9 Correct 0 ms 796 KB Output is correct
10 Correct 0 ms 796 KB Output is correct
11 Correct 0 ms 784 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 43 ms 9144 KB Wrong Answer [6]
2 Halted 0 ms 0 KB -