#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, 7, 56};
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);
}
}
return {1, 3};
assert(1 <= (int)can.size() && (int)can.size() <= 2);
if((int)can.size() == 1) return {can[0], 2};
return {can[0], can[1]};
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
5 ms |
200 KB |
Not correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
288 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |