Submission #704257

# Submission time Handle Problem Language Result Execution time Memory
704257 2023-03-02T02:06:19 Z vjudge1 Flight to the Ford (BOI22_communication) C++17
15 / 100
42 ms 1928 KB
#include <bits/stdc++.h>
using namespace std;

#include "communication.h"

void encode(int N, int X){
	// Solve for N <= 3
	if (X == 1){
		int c1 = send(0);
		if (c1 == 0){
			send(0);
			// message = 00 / 01
		}
		else{
			send(1);
			send(0);
			// message = 110 / 111
		}
	}
	else if (X == 2){
		int c1 = send(1);
		if (c1 == 0){
			send(0);
			// message = 00
		}
		else{
			int c2 = send(0);
			if (c2 == 0){
				send(0);
				// message = 100 / 101
			}
			else{
				send(0);
				// message = 110
			}
		}
	}
	else{
		int c1 = send(1);
		if (c1 == 0){
			send(1);
			// message = 01
		}
		else{
			int c2 = send(0);
			if (c2 == 0){
				send(0);
				// message = 100 / 101
			}
			else{
				send(1);
				// message = 111
			}
		}
	}
}

pair<int, int> decode(int N){
	int c1 = receive();
	if (c1 == 0){
		int c2 = receive();
		if (c2 == 0) return {1, 2};
		else return {1, 3};
	}
	else{
		int c2 = receive();
		int c3 = receive();

		if (c2 == 0) return {2, 3};
		if (c3 == 0) return {1, 2};
		else return {1, 3};
	}
}
# Verdict Execution time Memory Grader output
1 Correct 11 ms 1680 KB Output is correct
2 Correct 10 ms 1656 KB Output is correct
3 Correct 14 ms 1744 KB Output is correct
4 Correct 11 ms 1620 KB Output is correct
5 Correct 10 ms 1604 KB Output is correct
6 Correct 27 ms 1928 KB Output is correct
7 Correct 42 ms 1796 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 20 ms 192 KB Not correct
2 Halted 0 ms 0 KB -