이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <utility>
#include <bits/stdc++.h>
using namespace std;
/**
* use this function in encode when you want to send a certain signal
* (it might come out wrong, and the return value tells you which signal
* was actually sent)
*/
int send(int);
/**
* use this function in decode; it returns the next signal that was actually
* sent during the corresponding call of encode
*/
int receive();
/**
* implement these two functions yourself
*/
void encode(int N, int X){
for(int j = 0; j < 2; ++j){
bool val = (1<<j)&X;
send(val);
send(val);
send(val);
}
}
pair<int, int> decode(int N) {
int a = 0, b = 0;
int x[6];
for(int j = 0; j < 6; ++j) x[j] = receive();
bool f = 1, g = 1;
if(x[0] == x[1] || x[1] == x[2]){
a += x[1];
b += x[1];
}else{
a += 1;
f = 0;
}
if(x[3] == x[4] || x[4] == x[5]){
a += x[4] * 2;
b += x[4] * 2;
}else{
b += 2;
g = 0;
}
if(!f && !g) a = b = 3;
if(b==0) b++;
if(a==0) a++;
return {a, b};
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |