Submission #208636

# Submission time Handle Problem Language Result Execution time Memory
208636 2020-03-12T00:20:39 Z eriksuenderhauf Data Transfer (IOI19_transfer) C++14
100 / 100
279 ms 2664 KB
#include <bits/stdc++.h>
#include "transfer.h"
#define vi vector<int>
#define pb push_back
using namespace std;

vi get_attachment(vi source) {
	int n = source.size();
	vi ret;
	int xo = 0;
	for (int i = 0; i < n; i++)
		xo ^= source[i];
	ret.pb(xo);
	for (int i = 0; (1 << i) < n; i++) {
		xo = 0;
		for (int j = 0; j < n; j++)
			if ((j+1) & (1 << i))
				xo ^= source[j];
		ret.pb(xo);
	}
	return ret;
}

vi retrieve(vi data) {
	int n = data.size() < 255 ? 63 : 255;
	vi ret;
	int xo = 0;
	for (int i = 0; i < n; i++)
		xo ^= data[i];
	ret.pb(xo);
	for (int i = 0; (1 << i) < n; i++) {
		xo = 0;
		for (int j = 0; j < n; j++)
			if ((j+1) & (1 << i))
				xo ^= data[j];
		ret.pb(xo);
	}
	int k = data.size() - n;
	if (ret[0] == data[n])
		return vi(data.begin(), data.end() - k);
	int idx = 0;
	for (int i = 1; i < k; i++)
		if (ret[i] != data[n + i])
			idx |= (1 << (i-1));
	if (idx)
		data[idx-1] ^= 1;
	return vi(data.begin(), data.end() - k);
}
# Verdict Execution time Memory Grader output
1 Correct 15 ms 1128 KB Output is correct
2 Correct 15 ms 1124 KB Output is correct
3 Correct 15 ms 1136 KB Output is correct
4 Correct 15 ms 1140 KB Output is correct
5 Correct 15 ms 1260 KB Output is correct
6 Correct 15 ms 1128 KB Output is correct
7 Correct 15 ms 1024 KB Output is correct
8 Correct 15 ms 1132 KB Output is correct
9 Correct 15 ms 1112 KB Output is correct
10 Correct 15 ms 1132 KB Output is correct
11 Correct 15 ms 1132 KB Output is correct
12 Correct 16 ms 1128 KB Output is correct
13 Correct 15 ms 872 KB Output is correct
14 Correct 15 ms 1136 KB Output is correct
15 Correct 15 ms 1028 KB Output is correct
16 Correct 15 ms 980 KB Output is correct
17 Correct 15 ms 1140 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 270 ms 2660 KB Output is correct
2 Correct 271 ms 2656 KB Output is correct
3 Correct 263 ms 2656 KB Output is correct
4 Correct 259 ms 2612 KB Output is correct
5 Correct 254 ms 2660 KB Output is correct
6 Correct 262 ms 2648 KB Output is correct
7 Correct 262 ms 2664 KB Output is correct
8 Correct 259 ms 2608 KB Output is correct
9 Correct 264 ms 2632 KB Output is correct
10 Correct 260 ms 2660 KB Output is correct
11 Correct 272 ms 2648 KB Output is correct
12 Correct 258 ms 2656 KB Output is correct
13 Correct 279 ms 2660 KB Output is correct
14 Correct 261 ms 2660 KB Output is correct
15 Correct 272 ms 2652 KB Output is correct
16 Correct 258 ms 2664 KB Output is correct
17 Correct 259 ms 2612 KB Output is correct
18 Correct 267 ms 2664 KB Output is correct
19 Correct 253 ms 2652 KB Output is correct