답안 #941318

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
941318 2024-03-08T13:32:15 Z william950615 Flight to the Ford (BOI22_communication) C++17
0 / 100
14 ms 332 KB
#include"communication.h"
//#include<bits/stdc++.h>
//using namespace std;
//
// --- Sample implementation for the task communication ---
//
// To compile this program with the sample grader, place:
//     communication.h communication_sample.cpp sample_grader.cpp
// in a single folder, then open the terminal in this directory (right-click onto an empty spot in the directory,
// left click on "Open in terminal") and enter e.g.: //     g++ -std=c++17 communication_sample.cpp sample_grader.cpp
// in this folder. This will create a file a.out in the current directory which you can execute from the terminal
// as ./a.out
// See task statement or sample_grader.cpp for the input specification
//
void encode(int N, int X) {
	auto send_bit = [&](bool x, bool y) {
		send( x );
		send( x );
		send( y );
		send( x );
		send( y );
		send( y );
	};
	send_bit( (X>>1)&1, X&1 );
}

std::pair<int, int> decode(int N) {
	int ans[2];
	for( auto &i : ans ) i = -1;
	auto receive_bit = [&](int a, int b) {
		int bi[6];
		for( int i = 0; i < 6; ++i )
			bi[i] = receive();
		
		if( bi[0] == bi[1] ) 
			ans[a]=bi[0];
		if( bi[4] == bi[5] )
			ans[b]=bi[5];

		if( bi[1] != bi[3] )
			ans[b]=bi[2];
		if( bi[2] != bi[4] )
			ans[a]=bi[3];

	};
	receive_bit( 1, 0 );
//	assert( ans[1] != -1 || ans[0] != -1 );
//	cout << ans[0] << ' ' << ans[1] << '\n';
	if( ans[1] != -1 ) {
		if( ans[1] == 0 )
			return {1,2};
		else
			return {2,3};
	}
	if( ans[0] != -1 ) {
		if( ans[0] == 0 )
			return {2,3};
		else
			return {1,3};
	}
	return {1,2};
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 332 KB Not correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 14 ms 332 KB Not correct
2 Halted 0 ms 0 KB -