답안 #417312

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
417312 2021-06-03T14:42:21 Z tqbfjotld Ancient Machine (JOI21_ancient_machine) C++17
84 / 100
93 ms 7776 KB
#include "Anna.h"
#include <vector>
#include <string>
#include <cassert>
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+=58){
        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);
        }
        assert((state&(1LL<<46))==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:19:23: warning: comparison of integer expressions of different signedness: 'std::vector<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   19 |     while (S.size()%58!=(Xpos+1)%58){
      |            ~~~~~~~~~~~^~~~~~~~~~~~~
Anna.cpp:11:9: warning: variable 'Zpos' set but not used [-Wunused-but-set-variable]
   11 |     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 492 KB Output is correct
2 Correct 0 ms 484 KB Output is correct
3 Correct 0 ms 496 KB Output is correct
4 Correct 0 ms 484 KB Output is correct
5 Correct 0 ms 484 KB Output is correct
6 Correct 0 ms 484 KB Output is correct
7 Correct 0 ms 484 KB Output is correct
8 Correct 1 ms 444 KB Output is correct
9 Correct 0 ms 496 KB Output is correct
10 Correct 0 ms 484 KB Output is correct
11 Correct 0 ms 484 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Partially correct 79 ms 7776 KB Partially correct
2 Partially correct 78 ms 7488 KB Partially correct
3 Partially correct 77 ms 7480 KB Partially correct
4 Partially correct 78 ms 7484 KB Partially correct
5 Partially correct 79 ms 7492 KB Partially correct
6 Partially correct 78 ms 7652 KB Partially correct
7 Partially correct 90 ms 7504 KB Partially correct
8 Partially correct 81 ms 7424 KB Partially correct
9 Partially correct 79 ms 7604 KB Partially correct
10 Partially correct 77 ms 7408 KB Partially correct
11 Partially correct 78 ms 7500 KB Partially correct
12 Partially correct 78 ms 7468 KB Partially correct
13 Partially correct 84 ms 7660 KB Partially correct
14 Partially correct 87 ms 7416 KB Partially correct
15 Partially correct 80 ms 7496 KB Partially correct
16 Partially correct 90 ms 7536 KB Partially correct
17 Partially correct 82 ms 7704 KB Partially correct
18 Partially correct 84 ms 7512 KB Partially correct
19 Partially correct 83 ms 7492 KB Partially correct
20 Partially correct 79 ms 7488 KB Partially correct
21 Partially correct 78 ms 7496 KB Partially correct
22 Partially correct 84 ms 7652 KB Partially correct
23 Partially correct 91 ms 7480 KB Partially correct
24 Partially correct 78 ms 7508 KB Partially correct
25 Partially correct 86 ms 7548 KB Partially correct
26 Partially correct 93 ms 7648 KB Partially correct
27 Correct 55 ms 6420 KB Output is correct
28 Partially correct 88 ms 7700 KB Partially correct
29 Partially correct 86 ms 7520 KB Partially correct
30 Correct 54 ms 6368 KB Output is correct
31 Partially correct 84 ms 7476 KB Partially correct
32 Partially correct 83 ms 7608 KB Partially correct
33 Partially correct 84 ms 7488 KB Partially correct