#include <bits/stdc++.h>
#include"communication.h"
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvl = vector<vll>;
using pll = pair<ll,ll>;
using vpl = vector<pll>;
using vvp = vector<vpl>;
#define f first
#define s second
#define pb push_back
#define all(v) v.begin(),v.end()
// g++ -std=c++17 communication_sample.cpp sample_grader.cpp
// as ./a.exe
void encode(int n, int x) {
ll a, b;
if(x==1){
a=send(1);
b=send(0);
}
if(x==2){
a=send(0);
b=send(1);
}
if(x==3){
a=send(1);
b=send(1);
}
if(a==1 && b==1){
if(x==3)send(0);
else send(1);
}
}
std::pair<int, int> decode(int N) {
ll a, b, c;
a=receive();
b=receive();
if(a==0 && b==0)return {1,2};
if(a==0 && b==1)return {3,2};
if(a==1 && b==0)return {3,1};
if(a==1 && b==1){
c=receive();
if(c==0)return {2,3};
else return {1,3};
}
return {1,2};
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |