답안 #829570

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
829570 2023-08-18T12:56:31 Z MODDI Data Transfer (IOI19_transfer) C++14
0 / 100
5 ms 4472 KB
#include "transfer.h"
using namespace std;
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
vector<int> get_attachment(vector<int> source){
	int x = 0;
	vi ret = source;
	for(int i = 0; i < (int)source.size(); i++){
		if(source[i] == 1)
			x ^= (i+1);
	}
	int ones = 0;
	if(source.size() < 64){
		for(int i = 0; i < 6; i++){
			ret.pb(x&1);
			if(x&1) ones++;
			x >>=1;
		}
	}
	else
	{
		for(int i = 0; i < 8; i++){
			ret.pb(x&1);
			if(x&1) ones++;
			x>>=1;
		}
	}
	if(ones % 2 == 1)
		ret.pb(1);
	else
		ret.pb(0);
	return ret;
}
vector<int> retrieve(vector<int> data){
	int last = data.back();
	data.pop_back();
	int ac_last = 0, x = 0;
	if(data.size() < 71){
		for(int i = 0; i < 6; i++){
			x<<=1;
			x += data.back();
			if(data.back())	ac_last = 1 - ac_last;
			data.pop_back();
		}
	}
	else{
		for(int i = 0; i < 8; i++){
			x<<=1;
			x += data.back();
			if(data.back()) ac_last = 1 - ac_last;
			data.pop_back();
		}
	}
	if(ac_last != last)	return data;
	
	int ac_x = 0;
	for(int i = 0; i < (int)data.size(); i++){
		if(data[i]) ac_x ^= (i+1);
	}
	int error = ac_x ^ x;
	if(error == 0)	return data;
	
	data[error-1] = 1 - data[error-1];
	return data;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 900 KB WA in grader: wrong source retrieval
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 4472 KB WA in grader: wrong source retrieval
2 Halted 0 ms 0 KB -