Submission #144167

# Submission time Handle Problem Language Result Execution time Memory
144167 2019-08-16T09:12:58 Z tincamatei Data Transfer (IOI19_transfer) C++14
0 / 100
23 ms 2636 KB
#include "transfer.h"

std::vector<int> get_attachment(std::vector<int> source) {
	int N = source.size();
	int K;

	if(N == 63)
		K = 7;
	else
		K = 9;
	
	std::vector<int> attach(K, 0);

	for(int i = 0; i < N; ++i) {
		for(int j = 0; j < K - 1; ++j)
			if((1 << j) & i)
				attach[j] ^= source[i];
		attach[K - 1] ^= source[i]; 
	}

	return attach;
}

std::vector<int> retrieve(std::vector<int> data) {
	int N, K;

	if(data.size() == 70) {
		N = 63;
		K = 7;
	} else {
		N = 255;
		K = 9;
	}

	for(int i = 0; i < N; ++i) {
		for(int j = 0; j < K - 1; ++j)
			if((1 << j) & i)
				data[N + j] ^= data[i];
		data[N + K - 1] ^= data[i];
	}

	int badbit = 0;
	std::vector<int> rez;

	for(int i = 0; i < N; ++i)
		rez.push_back(data[i]);
	
	for(int j = 0; j < (K - 1); ++j)
		badbit |= (data[N + j] << j);
	
	if(data[N + K - 1] == 1)
		rez[badbit] ^= 1;

	return rez;
}
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 976 KB secret mismatch
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 23 ms 2636 KB secret mismatch
2 Halted 0 ms 0 KB -