Submission #601612

# Submission time Handle Problem Language Result Execution time Memory
601612 2022-07-22T08:38:26 Z 이동현(#8475) Flight to the Ford (BOI22_communication) C++17
15 / 100
194 ms 1856 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, 1, 18, 78};

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

std::pair<int, int> decode(int N) {
    int val = 0;
    for(int i = 0; i < 30; ++i){
        val += (receive() << i);
    }
    vector<int> can;
    for(int i = 1; i <= 3; ++i){
        int lst = 0;
        for(int j = 0; j < 30; ++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]};
}
# Verdict Execution time Memory Grader output
1 Correct 42 ms 1748 KB Output is correct
2 Correct 29 ms 1736 KB Output is correct
3 Correct 40 ms 1620 KB Output is correct
4 Correct 29 ms 1600 KB Output is correct
5 Correct 50 ms 1720 KB Output is correct
6 Correct 111 ms 1856 KB Output is correct
7 Correct 194 ms 1684 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 292 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -