Submission #789671

# Submission time Handle Problem Language Result Execution time Memory
789671 2023-07-21T17:14:36 Z radaiosm7 Data Transfer (IOI19_transfer) C++17
100 / 100
45 ms 2496 KB
#include "transfer.h"
#include <bits/stdc++.h>
using namespace std;
int n, k, i, j, c[3];
vector<int> att;

vector<int> get_attachment(vector<int> source) {
	att.clear();
	n = (int)source.size();
	c[0] = 0;
	c[2] = 0;
	k = (n == 63) ? 6 : 8;

	for (i=1; i <= n; ++i) if (source[i-1] == 0) c[0] ^= i;
	for (i=0; i < k; ++i) (c[0] & (1 << i)) ? (att.push_back(1)) : (att.push_back(0));
	for (i=0; i < k; ++i) c[2] ^= att[i];
	att.push_back(c[2]);
	return att;
}

vector<int> retrieve(vector<int> data) {
	n = (int)data.size();
	k = (n == 70) ? 6 : 8;
	n -= k+1;
	c[0] = 0;
	c[1] = 0;
	c[2] = 0;

	for (i=1; i <= n; ++i) if (data[i-1] == 0) c[0] ^= i;
	for (j=0; j < k; ++j) if (data[n+j] == 1) c[1] += (1 << j);
	for (j=0; j < k; ++j) c[2] ^= data[n+j];
	if (c[0] != c[1] && c[2] == data[n+k]) data[(c[0]^c[1])-1] ^= 1;
	data.resize(n);
	return data;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 644 KB Output is correct
2 Correct 2 ms 644 KB Output is correct
3 Correct 2 ms 644 KB Output is correct
4 Correct 2 ms 732 KB Output is correct
5 Correct 2 ms 728 KB Output is correct
6 Correct 2 ms 740 KB Output is correct
7 Correct 2 ms 652 KB Output is correct
8 Correct 2 ms 652 KB Output is correct
9 Correct 2 ms 652 KB Output is correct
10 Correct 2 ms 728 KB Output is correct
11 Correct 2 ms 644 KB Output is correct
12 Correct 2 ms 728 KB Output is correct
13 Correct 2 ms 644 KB Output is correct
14 Correct 2 ms 652 KB Output is correct
15 Correct 2 ms 728 KB Output is correct
16 Correct 2 ms 652 KB Output is correct
17 Correct 2 ms 728 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 39 ms 2404 KB Output is correct
2 Correct 34 ms 2428 KB Output is correct
3 Correct 34 ms 2496 KB Output is correct
4 Correct 35 ms 2496 KB Output is correct
5 Correct 43 ms 2492 KB Output is correct
6 Correct 45 ms 2488 KB Output is correct
7 Correct 41 ms 2448 KB Output is correct
8 Correct 37 ms 2464 KB Output is correct
9 Correct 42 ms 2488 KB Output is correct
10 Correct 34 ms 2460 KB Output is correct
11 Correct 33 ms 2496 KB Output is correct
12 Correct 35 ms 2488 KB Output is correct
13 Correct 35 ms 2496 KB Output is correct
14 Correct 39 ms 2484 KB Output is correct
15 Correct 37 ms 2492 KB Output is correct
16 Correct 38 ms 2448 KB Output is correct
17 Correct 37 ms 2496 KB Output is correct
18 Correct 37 ms 2448 KB Output is correct
19 Correct 36 ms 2488 KB Output is correct