Submission #704255

# Submission time Handle Problem Language Result Execution time Memory
704255 2023-03-02T02:05:59 Z TranGiaHuy1508 Flight to the Ford (BOI22_communication) C++17
15 / 100
37 ms 1820 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 8 ms 1796 KB Output is correct
2 Correct 11 ms 1800 KB Output is correct
3 Correct 11 ms 1692 KB Output is correct
4 Correct 10 ms 1732 KB Output is correct
5 Correct 8 ms 1600 KB Output is correct
6 Correct 22 ms 1820 KB Output is correct
7 Correct 37 ms 1664 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 9 ms 200 KB Not correct
2 Halted 0 ms 0 KB -