Submission #874831

# Submission time Handle Problem Language Result Execution time Memory
874831 2023-11-17T21:37:21 Z rainboy Data Transfer (IOI19_transfer) C++17
100 / 100
74 ms 2760 KB
#include "transfer.h"
#include <vector>

using namespace std;

typedef vector<int> vi;

vi get_attachment(vi aa) {
	int n = aa.size(), l = 0;
	while (1 << l <= n)
		l++;
	vi xx(l + 1, 0);
	int x = 0;
	for (int i = 0; i < n; i++)
		if (aa[i] == 1)
			x ^= i + 1;
	int k = 0;
	for (int h = 0; h < l; h++)
		if ((x & 1 << h) != 0)
			xx[h] = 1, k++;
	if (k % 2 != 0)
		xx[l] = 1;
	return xx;
}

vi retrieve(vi bb) {
	int m = bb.size(), n = 0, l = 0;
	while (1) {
		n++;
		while (1 << l <= n)
			l++;
		if (m == n + l + 1)
			break;
	}
	int x = 0, k = 0;
	for (int h = 0; h <= l; h++)
		if (bb[n + h] == 1) {
			if (h < l)
				x |= 1 << h;
			k++;
		}
	bb.resize(n);
	if (k % 2 == 0) {
		for (int i = 0; i < n; i++)
			if (bb[i] == 1)
				x ^= i + 1;
		if (x != 0)
			bb[x - 1] ^= 1;
	}
	return bb;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 800 KB Output is correct
2 Correct 1 ms 800 KB Output is correct
3 Correct 1 ms 820 KB Output is correct
4 Correct 1 ms 1296 KB Output is correct
5 Correct 2 ms 792 KB Output is correct
6 Correct 2 ms 792 KB Output is correct
7 Correct 1 ms 784 KB Output is correct
8 Correct 1 ms 800 KB Output is correct
9 Correct 1 ms 804 KB Output is correct
10 Correct 2 ms 800 KB Output is correct
11 Correct 1 ms 792 KB Output is correct
12 Correct 3 ms 1068 KB Output is correct
13 Correct 1 ms 796 KB Output is correct
14 Correct 1 ms 784 KB Output is correct
15 Correct 2 ms 1012 KB Output is correct
16 Correct 1 ms 800 KB Output is correct
17 Correct 2 ms 784 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 46 ms 2512 KB Output is correct
2 Correct 53 ms 2504 KB Output is correct
3 Correct 46 ms 2512 KB Output is correct
4 Correct 51 ms 2512 KB Output is correct
5 Correct 74 ms 2512 KB Output is correct
6 Correct 66 ms 2512 KB Output is correct
7 Correct 57 ms 2516 KB Output is correct
8 Correct 50 ms 2512 KB Output is correct
9 Correct 45 ms 2760 KB Output is correct
10 Correct 45 ms 2516 KB Output is correct
11 Correct 44 ms 2512 KB Output is correct
12 Correct 46 ms 2508 KB Output is correct
13 Correct 45 ms 2516 KB Output is correct
14 Correct 66 ms 2516 KB Output is correct
15 Correct 51 ms 2516 KB Output is correct
16 Correct 57 ms 2508 KB Output is correct
17 Correct 52 ms 2508 KB Output is correct
18 Correct 49 ms 2520 KB Output is correct
19 Correct 46 ms 2512 KB Output is correct