답안 #601603

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
601603 2022-07-22T08:32:34 Z 이동현(#8475) Flight to the Ford (BOI22_communication) C++17
0 / 100
3 ms 328 KB
#include"communication.h"
#include <bits/stdc++.h>
using namespace std;
//
// --- Sample implementation for the task communication ---
//
// To compile this program with the sample grader, place:
//     communication.h communication_sample.cpp sample_grader.cpp
// in a single folder, then open the terminal in this directory (right-click onto an empty spot in the directory,
// left click on "Open in terminal") and enter e.g.:
//     g++ -std=c++17 communication_sample.cpp sample_grader.cpp
// in this folder. This will create a file a.out in the current directory which you can execute from the terminal
// as ./a.out
// See task statement or sample_grader.cpp for the input specification
//
int a[4] = {0, 0, 34, 98};

void encode(int N, int X) {
    for(int i = 0; i < 6; ++i){
        send((a[X] >> i) & 1);
    }
}

std::pair<int, int> decode(int N) {
    int val = 0;
    for(int i = 0; i < 6; ++i){
        val += (receive() << i);
    }
    vector<int> can;
    for(int i = 1; i <= 3; ++i){
        int lst = 0;
        for(int j = 0; j < 6; ++j){
            if(((val >> j) & 1) ^ ((a[i] >> j) & 1)){
                if(lst){
                    lst = -1;
                    break;
                }
                lst = 1;
            }
            else{
                lst = 0;
            }
        }
        if(lst != -1){
            can.push_back(i);
        }
    }
    if(!(1 <= (int)can.size() && (int)can.size() <= 2)) while(true) cout <<"SDF";
    if((int)can.size() == 1) return {can[0], 2};
    return {can[0], can[1]};
}
# 결과 실행 시간 메모리 Grader output
1 Failed 3 ms 200 KB Length of token exceeds 33554432, token is 'SDFSDFSDFSDFSDFSDFSDFSDFSDFSDF...FSDFSDFSDFSDFSDFSDFSDFSDFSDFSDF...' (instance_decoder_0)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 328 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -