Submission #595466

# Submission time Handle Problem Language Result Execution time Memory
595466 2022-07-13T18:47:05 Z Blagojce Flight to the Ford (BOI22_communication) C++17
0 / 100
1062 ms 1796 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 C = 0;
	
	while(pos < 30){
		int bit = 0;
		if(X & (1<<pos)) bit = 1;
		
		int c = rand() + pos;
		int nxt = V[c%100];
		
		
		if(c % 4){
			++C;
			if(C > 250)cout<<2/0<<endl;
			int r = send(nxt);
		
			if(r != nxt){++C;
			if(C > 250)cout<<2/0<<endl;
				send(bit);
				++pos;
			}
		}
		else{++C;
			if(C > 250)cout<<2/0<<endl;
			int r1 = send(bit);++C;
			if(C > 250)cout<<2/0<<endl;
			int r2 = send(bit);++C;
			if(C > 250)cout<<2/0<<endl;
			int r3 = send(bit);++C;
			if(C > 250)cout<<2/0<<endl;
			int r4 = send(bit);
		
			if(r1 == r2 || r2 == r3 || r3 == r4){
				++pos;
			}
		}
	}
}
 
 
std::pair<int, int> decode(int N){
	srand(N);
	int pos = 0;
	
	int X = 0;
	int C = 0;
	while(pos < 30){
		int c = rand() + pos;
		int nxt = V[c%100];
		
		
		
		if(c % 4){
			++C;
			if(C > 250)cout<<2/0<<endl;
			int r = receive();
			
			if(r != nxt){
				
				++C;
				if(C > 250)cout<<2/0<<endl;
				
				int bit = receive();
				if(bit == 1) X |= (1<<pos);
				++pos;
			}
		}
		else{
			
			++C;
			if(C > 250)cout<<2/0<<endl;
			int r1 = receive();
			
			
			++C;
			if(C > 250)cout<<2/0<<endl;
			int r2 = receive();
			
			
			++C;
			if(C > 250)cout<<2/0<<endl;
			int r3 = receive();
			
			
			++C;
			if(C > 250)cout<<2/0<<endl;
			int r4 = receive();
		
			if(r1 == r2){
				if(r1 == 1) X |= (1<<pos);
				++pos;
			}
			else if(r2 == r3){
				if(r2 == 1) X |= (1<<pos);
				++pos;
			}
			else if(r3 == r4){
				if(r3 == 1) X |= (1<<pos);
				++pos;
			}
		}
	}
	
	return {X, 1};
		
}/*
int main(){
	encode(10, 1);
	decode(10);
}
*/

Compilation message

communication.cpp: In function 'void encode(int, int)':
communication.cpp:53:22: warning: division by zero [-Wdiv-by-zero]
   53 |    if(C > 250)cout<<2/0<<endl;
      |                     ~^~
communication.cpp:57:22: warning: division by zero [-Wdiv-by-zero]
   57 |    if(C > 250)cout<<2/0<<endl;
      |                     ~^~
communication.cpp:63:22: warning: division by zero [-Wdiv-by-zero]
   63 |    if(C > 250)cout<<2/0<<endl;
      |                     ~^~
communication.cpp:65:22: warning: division by zero [-Wdiv-by-zero]
   65 |    if(C > 250)cout<<2/0<<endl;
      |                     ~^~
communication.cpp:67:22: warning: division by zero [-Wdiv-by-zero]
   67 |    if(C > 250)cout<<2/0<<endl;
      |                     ~^~
communication.cpp:69:22: warning: division by zero [-Wdiv-by-zero]
   69 |    if(C > 250)cout<<2/0<<endl;
      |                     ~^~
communication.cpp: In function 'std::pair<int, int> decode(int)':
communication.cpp:94:22: warning: division by zero [-Wdiv-by-zero]
   94 |    if(C > 250)cout<<2/0<<endl;
      |                     ~^~
communication.cpp:100:23: warning: division by zero [-Wdiv-by-zero]
  100 |     if(C > 250)cout<<2/0<<endl;
      |                      ~^~
communication.cpp:110:22: warning: division by zero [-Wdiv-by-zero]
  110 |    if(C > 250)cout<<2/0<<endl;
      |                     ~^~
communication.cpp:115:22: warning: division by zero [-Wdiv-by-zero]
  115 |    if(C > 250)cout<<2/0<<endl;
      |                     ~^~
communication.cpp:120:22: warning: division by zero [-Wdiv-by-zero]
  120 |    if(C > 250)cout<<2/0<<endl;
      |                     ~^~
communication.cpp:125:22: warning: division by zero [-Wdiv-by-zero]
  125 |    if(C > 250)cout<<2/0<<endl;
      |                     ~^~
# Verdict Execution time Memory Grader output
1 Correct 77 ms 1732 KB Output is correct
2 Correct 133 ms 1664 KB Output is correct
3 Correct 240 ms 1796 KB Output is correct
4 Correct 128 ms 1696 KB Output is correct
5 Correct 175 ms 1724 KB Output is correct
6 Runtime error 3 ms 424 KB Execution killed with signal 4
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Partially correct 941 ms 1704 KB Output is partially correct
2 Partially correct 444 ms 1740 KB Output is partially correct
3 Partially correct 541 ms 1664 KB Output is partially correct
4 Partially correct 876 ms 1680 KB Output is partially correct
5 Partially correct 833 ms 1704 KB Output is partially correct
6 Partially correct 1062 ms 1764 KB Output is partially correct
7 Runtime error 2 ms 288 KB Execution killed with signal 4
8 Halted 0 ms 0 KB -