Submission #748036

# Submission time Handle Problem Language Result Execution time Memory
748036 2023-05-25T10:26:19 Z FulopMate Data Transfer (IOI19_transfer) C++17
80 / 100
1694 ms 2512 KB
#include "transfer.h"

#include <bits/stdc++.h>

using namespace std;

vector<int> get_attachment(vector<int> source) {
	vector<int> res;
	int K = log2(source.size()+1);
	int safe = 0;
	for (int i = 0; i <= K; i++) {
		int x = 0;
		int block = 1 << i;
		for (int j = 0; j < source.size(); j++) {
			if ((j / block) % 2 == 0) {
				x ^= source[j];
			}
		}
		res.push_back(x);
		safe ^= x;
	}
	res.push_back(safe);
	return res;
}

vector<int> retrieve(vector<int> data) {
	int n;
	if (data.size() < 100) {
		n = 63;
	} else {
		n = 255;
	}
	int K = log2(n+1);
	int safe = data.back();
	vector<int> source = vector<int>(data.begin(), data.begin()+n);
	vector<int> cnt(n);
	vector<int> v = vector<int>(data.begin()+n, data.end()-1);
	int p = 0;
	for (int i : v) p ^= i;
	if (p != safe) return source;
	for (int i = 0; i <= K; i++) {
		int x = 0;
		int block = 1 << i;
		for (int j = 0; j < n; j++) {
			if ((j / block) % 2 == 0) {
				x ^= source[j];
			}
		}
		for (int j = 0; j < n; j++) {
			if ((j / block) % 2 == (x == v[i])) {
				cnt[j]++;
			}
		}
	}
	for (int i = 0; i < n; i++) {
		if (cnt[i] == K+1) {
			source[i] ^= 1;
			return source;
		}
	}
	return source;
}

Compilation message

transfer.cpp: In function 'std::vector<int> get_attachment(std::vector<int>)':
transfer.cpp:14:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   14 |   for (int j = 0; j < source.size(); j++) {
      |                   ~~^~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Partially correct 21 ms 652 KB Partially correct
2 Partially correct 21 ms 648 KB Partially correct
3 Partially correct 23 ms 652 KB Partially correct
4 Partially correct 21 ms 732 KB Partially correct
5 Partially correct 21 ms 652 KB Partially correct
6 Partially correct 22 ms 744 KB Partially correct
7 Partially correct 22 ms 720 KB Partially correct
8 Partially correct 21 ms 652 KB Partially correct
9 Partially correct 21 ms 804 KB Partially correct
10 Partially correct 21 ms 704 KB Partially correct
11 Partially correct 21 ms 752 KB Partially correct
12 Partially correct 21 ms 644 KB Partially correct
13 Partially correct 23 ms 644 KB Partially correct
14 Partially correct 21 ms 724 KB Partially correct
15 Partially correct 21 ms 644 KB Partially correct
16 Partially correct 23 ms 744 KB Partially correct
17 Partially correct 22 ms 648 KB Partially correct
# Verdict Execution time Memory Grader output
1 Partially correct 1585 ms 2492 KB Partially correct
2 Partially correct 1558 ms 2492 KB Partially correct
3 Partially correct 1542 ms 2500 KB Partially correct
4 Partially correct 1591 ms 2500 KB Partially correct
5 Partially correct 1662 ms 2464 KB Partially correct
6 Partially correct 1640 ms 2500 KB Partially correct
7 Partially correct 1694 ms 2484 KB Partially correct
8 Partially correct 1581 ms 2488 KB Partially correct
9 Partially correct 1573 ms 2512 KB Partially correct
10 Partially correct 1576 ms 2492 KB Partially correct
11 Partially correct 1564 ms 2504 KB Partially correct
12 Partially correct 1559 ms 2476 KB Partially correct
13 Partially correct 1564 ms 2492 KB Partially correct
14 Partially correct 1556 ms 2500 KB Partially correct
15 Partially correct 1552 ms 2500 KB Partially correct
16 Partially correct 1564 ms 2500 KB Partially correct
17 Partially correct 1559 ms 2472 KB Partially correct
18 Partially correct 1553 ms 2504 KB Partially correct
19 Partially correct 1571 ms 2404 KB Partially correct