답안 #417127

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
417127 2021-06-03T12:01:08 Z tqbfjotld Ancient Machine (JOI21_ancient_machine) C++17
0 / 100
30 ms 3328 KB
#include "Anna.h"
#include <vector>
using namespace std;

///17 bits for 1st X, N bits for isZ
void Anna(int N, std::vector<char> S) {
    int Xpos = -1;
    int Zpos = -1;
    for (int x = 0; x<N; x++){
        if (S[x]=='Z') Zpos = x;
        if (Xpos==-1 && S[x]=='X') Xpos = x;
    }
    for (int x = 16; x>=0; x--){
        Send((bool)(Xpos&(1<<x)));
    }
    for (int x = 0; x<N; x++){
        Send(S[x]=='Z');
    }
}
#include "Bruno.h"
#include <vector>
#include <cassert>
using namespace std;


void Bruno(int N, int L, std::vector<int> A) {
    assert(L==N+17);
    int Xpos = 0;
    int Zpos = 0;
    for (int x = 0; x<17; x++){
        Xpos = (Xpos<<1)+A[x];
    }

    if (Xpos==(1<<17)-1){
        for (int x = 0; x<N; x++){
            Remove(x);
        }
        return;
    }
    vector<int> rem;
    for (int x = 0; x<Xpos; x++){
        Remove(x);
    }
    for (int x = Xpos+1; x<N; x++){
        if (A[x-17]){
            while (!rem.empty()){
                Remove(rem.back());
                rem.pop_back();
            }
            Remove(x);
        }
        else{
            rem.push_back(x);
        }
    }
    Remove(Xpos);
    for (auto x : rem){
        Remove(x);
    }
}

Compilation message

Anna.cpp: In function 'void Anna(int, std::vector<char>)':
Anna.cpp:8:9: warning: variable 'Zpos' set but not used [-Wunused-but-set-variable]
    8 |     int Zpos = -1;
      |         ^~~~

Bruno.cpp: In function 'void Bruno(int, int, std::vector<int>)':
Bruno.cpp:10:9: warning: unused variable 'Zpos' [-Wunused-variable]
   10 |     int Zpos = 0;
      |         ^~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 492 KB Wrong Answer [6]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 30 ms 3328 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -