This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "communication.h"
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb emplace_back
#define ALL(x) x.begin(),x.end()
#define SZ(x) (int)x.size()
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<ii,ii> i4;
typedef vector<int> vi;
const int MOD=1000000007;
const int INF=1012345678;
const ll LLINF=1012345678012345678LL;
const double PI=3.1415926536;
const double EPS=1e-14;
void encode(int N, int X) {
if(X==1){
int x=send(0);
if(x==0){
int y=send(0);
if(y==0){
send(0); // 00x
}else{
send(0); // 010
}
}else{
send(0);
send(0); // 10x
}
}else if(X==2){
int x=send(0);
if(x==0){
int y=send(0);
if(y==0){
send(0); // 00x
}else{
send(1); // 011
}
}else{
send(1);
send(1); // 11x
}
}else{
int x=send(1);
if(x==1){
int y=send(0);
if(y==0){
send(0); // 10x
}else{
send(0); // 110
}
}else{
send(1);
send(1); // 01x
}
}
}
pair<int, int> decode(int N) {
int x=receive();
int y=receive();
int z=receive();
if(x==0&&y==0)return {1,2};
if(x==0&&y==1&&z==1)return {2,3};
if(x!=y)return {1,3};
return {2,3};
}
/*
000 1 2
001 1 2
010 1 3
011 2 3
100 1 3
101 1 3
110 2 3
111 2
*/
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |