Submission #735867

# Submission time Handle Problem Language Result Execution time Memory
735867 2023-05-04T20:49:00 Z rnl42 Data Transfer (IOI19_transfer) C++14
60 / 100
7 ms 2996 KB
#include "transfer.h"
using namespace std;

vector<int> get_attachment(vector<int> source) {
	const int N = source.size();
	//assert(__builtin_popcount(N+1) == 1);
	const int K = __lg(N+1)+1;
	vector<int> attach(K);
	for (int i = 0; i < N; i++) {
		for (int b = 0; b < K-1; b++) {
			if (((i+1) >> b) & 1) {
				attach[b] ^= source[i];
			}
		}
		attach.back() ^= source[i];
	}
	return attach;
}

vector<int> retrieve(vector<int> data) {
	int N = data.size();
	int K = __lg(N)+1;
	N -= K;

	vector<int> source(data.begin(), data.begin() + N);
	vector<int> newattach = get_attachment(source);
	int i = 0;
	for (int b = 0; b < K-1; b++) {
		if (newattach[b] != data[N+b]) {
			i |= (1<<b);
		}
	}
	i--;
	if (newattach.back() != data.back()) {
		if (i != -1) source[i] ^= 1;
	} else {
		if (i != -1) source[N+__lg(i+1)] ^= 1;
	}
	return source;
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 624 KB Output is correct
2 Correct 6 ms 644 KB Output is correct
3 Correct 6 ms 732 KB Output is correct
4 Correct 6 ms 820 KB Output is correct
5 Correct 5 ms 740 KB Output is correct
6 Correct 5 ms 644 KB Output is correct
7 Correct 7 ms 644 KB Output is correct
8 Correct 5 ms 644 KB Output is correct
9 Correct 5 ms 652 KB Output is correct
10 Correct 6 ms 644 KB Output is correct
11 Correct 5 ms 644 KB Output is correct
12 Correct 5 ms 652 KB Output is correct
13 Correct 5 ms 644 KB Output is correct
14 Correct 5 ms 652 KB Output is correct
15 Correct 5 ms 652 KB Output is correct
16 Correct 7 ms 652 KB Output is correct
17 Correct 5 ms 644 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 6 ms 2996 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -