Submission #595453

# Submission time Handle Problem Language Result Execution time Memory
595453 2022-07-13T18:37:32 Z Blagojce Flight to the Ford (BOI22_communication) C++17
0 / 100
21 ms 1784 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){
	srand(N);
	int pos = 0;
	
	int L = 0;
	
	while(pos < 2){
		int bit = 0;
		if(X & (1<<pos)) bit = 1;
		
		int c = rand() + pos + L;
		int nxt = V[c%100];
		
		
		if(c % 4){
			int r = send(nxt);
			L += r;
			if(r != nxt){
				send(bit);
				++pos;
			}
		}
		else{
			int r1 = send(bit^nxt);
			int r2 = send(bit^nxt);
			L += r1 + r2;
			if(r1 == r2){
				++pos;
			}
		}
	}

}
 
 
std::pair<int, int> decode(int N){
	srand(N);
	int pos = 0;
	
	int X = 0;
	int L = 0;
	
	while(pos < 2){
		int c = rand() + pos + L;
		int nxt = V[c%100];
		
		
		if(c % 4){
			int r = receive();
			L += r;
			if(r != nxt){
				int bit = receive();
				if(bit == 1) X |= (1<<pos);
				++pos;
			}
		}
		else{
			int r1 = receive();
			int r2 = receive();
			L += r1 + r2;
			if(r1 == r2){
				if(r1^nxt == 1) X |= (1<<pos);
				++pos;
			}
		}
	}
	
	return {X, X};
		
}/*
int main(){
	encode(10, 1);
	decode(10);
}
*/

Compilation message

communication.cpp: In function 'std::pair<int, int> decode(int)':
communication.cpp:98:15: warning: suggest parentheses around comparison in operand of '^' [-Wparentheses]
   98 |     if(r1^nxt == 1) X |= (1<<pos);
      |           ~~~~^~~~
# Verdict Execution time Memory Grader output
1 Correct 8 ms 1700 KB Output is correct
2 Correct 15 ms 1696 KB Output is correct
3 Correct 14 ms 1664 KB Output is correct
4 Correct 13 ms 1784 KB Output is correct
5 Correct 21 ms 1768 KB Output is correct
6 Incorrect 3 ms 204 KB Not correct
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 19 ms 200 KB Not correct
2 Halted 0 ms 0 KB -