답안 #417306

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
417306 2021-06-03T14:35:34 Z tqbfjotld Ancient Machine (JOI21_ancient_machine) C++17
5 / 100
102 ms 8572 KB
#include "Anna.h"
#include <vector>
#include <string>
using namespace std;


///log_3(2^N) +17 bits?
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)));
    }
    while (S.size()%58!=(Xpos+1)%58){
        S.push_back('X');
    }
    for (int x = Xpos+1; x<N; x+=29){
        long long state = 0;
        for (int y = 0; y<58; y+=2){
            string t = "";
            t.push_back(S[x+y]);
            t.push_back(S[x+y+1]);
            vector<string> opt0 = {"XX","XY","YX","YY"};
            vector<string> opt1 = {"XZ","YZ","ZZ"};
            vector<string> opt2 = {"ZX","ZY"};
            state *= 3;
            for (auto x : opt0){
                if (x==t) state += 0;
            }
            for (auto x : opt1){
                if (x==t) state += 1;
            }
            for (auto x : opt2){
                if (x==t) state += 2;
            }
        }
        for (int x = 45; x>=0; x--){
            if (state&(1LL<<x)){
                Send(1);
            }
            else Send(0);
        }

        //printf("%lld\n",state);
    }
}
#include "Bruno.h"
#include <vector>
#include <cassert>
#include <algorithm>
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);
    }
    int c = Xpos+1;
    for (int x = 17; x<A.size(); x+=46){
        long long state = 0;
        for (int y = 0; y<46; y++){
            state *= 2LL;
            state += (long long)A[x+y];
        }
        //printf("%lld\n",state);
        vector<int> things;
        for (int x = 0; x<29; x++){
            things.push_back(state%3);
            state /= 3;
        }
        reverse(things.begin(),things.end());
        for (int y = 0; y<29; y++){
            if (things[y]==0){
                rem.push_back(c+2*y);
                rem.push_back(c+2*y+1);
            }
            else if (things[y]==1){
                Remove(c+2*y);
                while (!rem.empty()){
                    Remove(rem.back());
                    rem.pop_back();
                }
                Remove(c+y*2+1);
            }
            else if (things[y]==2){
                while (!rem.empty()){
                    Remove(rem.back());
                    rem.pop_back();
                }
                Remove(c+2*y);
                rem.push_back(c+y*2+1);
            }
        }
        c+=58;
    }
    Remove(Xpos);
    for (auto x : rem){
        if (x<N)
        Remove(x);
    }
}

Compilation message

Anna.cpp: In function 'void Anna(int, std::vector<char>)':
Anna.cpp:18:23: warning: comparison of integer expressions of different signedness: 'std::vector<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   18 |     while (S.size()%58!=(Xpos+1)%58){
      |            ~~~~~~~~~~~^~~~~~~~~~~~~
Anna.cpp:10:9: warning: variable 'Zpos' set but not used [-Wunused-but-set-variable]
   10 |     int Zpos = -1;
      |         ^~~~

Bruno.cpp: In function 'void Bruno(int, int, std::vector<int>)':
Bruno.cpp:27:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |     for (int x = 17; x<A.size(); x+=46){
      |                      ~^~~~~~~~~
Bruno.cpp:11:9: warning: unused variable 'Zpos' [-Wunused-variable]
   11 |     int Zpos = 0;
      |         ^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 480 KB Output is correct
2 Correct 0 ms 484 KB Output is correct
3 Correct 1 ms 488 KB Output is correct
4 Correct 1 ms 496 KB Output is correct
5 Correct 0 ms 484 KB Output is correct
6 Correct 0 ms 488 KB Output is correct
7 Correct 0 ms 488 KB Output is correct
8 Correct 0 ms 492 KB Output is correct
9 Correct 0 ms 564 KB Output is correct
10 Correct 1 ms 488 KB Output is correct
11 Correct 0 ms 560 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 102 ms 8572 KB Wrong Answer [3]
2 Halted 0 ms 0 KB -