Submission #742444

#TimeUsernameProblemLanguageResultExecution timeMemory
742444jamielimFlight to the Ford (BOI22_communication)C++17
15 / 100
38 ms1748 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...