Submission #595486

# Submission time Handle Problem Language Result Execution time Memory
595486 2022-07-13T18:55:59 Z Blagojce Flight to the Ford (BOI22_communication) C++17
0 / 100
3 ms 284 KB
#include <bits/stdc++.h>
#define fr(i, n, m) for(int i = (n); i < (m); i ++)
#define st first
#define nd second
#define pb push_back
#define pq priority_queue
#define all(x) begin(x), end(x)
 
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
 
#include "communication.h"
 
vector<int> V = {1,1,0,0,1,0,0,0,0,0,1,1,1,1,1,1,1,0,1,0,1,0,0,1,0,0,1,0,0,1,1,0,1,0,1,0,1,1,1,0,1,1,0,1,1,0,1,1,1,0,1,0,0,1,1,1,1,1,1,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1,0,0,0,1,1,0,1,1,0,0,0,0,0,0,1,0,0,1,0,1,1,0,0,0,1,1};
 
 
//bool aux[250];
/*
 
vector<int> v;
int send(int x){
	cout<<x<<" SENDED"<<endl;
	int c;
	cin >> c;
	v.pb(c);
	return c;
}
int P = 0;
int receive(){
	cout<<"SEND ME"<<endl;
	int c;
	return v[P++];
}
*/
void encode(int N, int X){
	int b1 = 0;
	int b2 = 0;
	if(X&1) b1 = 1;
	if(X&2) b2 = 1;
	
	
	fr(i, 0, 50){
		send(b1);
	
	}
	fr(i, 0, 50){
		int t = send(1);
		if(t == 0){
			send(b1);
			fr(j, i+2, 50) send(1);
		}
	}
	
	
	
	
	fr(i, 0, 50){
		send(b2);
	
	}
	fr(i, 0, 50){
		int t = send(1);
		if(t == 0){
			send(b2);
			fr(j, i+2, 50) send(1);
		}
	}
}
 
 
std::pair<int, int> decode(int N){
	int b1 = 0, b2 = 0;
	
	int pr = receive();
	fr(i, 1, 50){
		int r = receive();
		if(pr == r){
			b1 = r;
		}
		pr = r;
	}
	fr(i, 0, 50){
		int r = receive();
		if(r == 0){
			r = receive();
			b1 = r;
			fr(j, i+2, 50) receive();
		}
	}
	
	pr = receive();
	fr(i, 1, 50){
		int r = receive();
		if(pr == r){
			b2 = r;
		}
		pr = r;
	}
	fr(i, 0, 50){
		int r = receive();
		if(r == 0){
			r = receive();
			b2 = r;
			fr(j, i+2, 50) receive();
		}
	}
	int X = (b1<<0)|(b2<<1);
	
	return {X, X};
	
	
	
	
	
	
		
}/*
int main(){
	encode(10, 1);
	decode(10);
}
*/
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 200 KB Not correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 284 KB Not correct
2 Halted 0 ms 0 KB -