Submission #748032

# Submission time Handle Problem Language Result Execution time Memory
748032 2023-05-25T10:21:34 Z FulopMate Data Transfer (IOI19_transfer) C++17
0 / 100
9 ms 2500 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);
	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);
	}
	return res;
}

vector<int> retrieve(vector<int> data) {
	int n;
	if (data.size() < 100) {
		n = 63;
	} else {
		n = 255;
	}
	int K = log2(n+1);
	vector<int> source = vector<int>(data.begin(), data.begin()+n);
	vector<int> cnt(n);
	vector<int> v = vector<int>(data.begin()+n+1, data.end());
	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:13:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   13 |   for (int j = 0; j < source.size(); j++) {
      |                   ~~^~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 648 KB WA in grader: wrong source retrieval
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 9 ms 2500 KB WA in grader: wrong source retrieval
2 Halted 0 ms 0 KB -