Submission #980697

# Submission time Handle Problem Language Result Execution time Memory
980697 2024-05-12T10:28:44 Z penguin133 Data Transfer (IOI19_transfer) C++17
0 / 100
32 ms 2504 KB
#include <bits/stdc++.h>
using namespace std;
#include "transfer.h"
//#define int long long
#define pi pair<int, int>
#define pii pair<int, pi>
#define fi first
#define se second
#ifdef _WIN32
#define getchar_unlocked _getchar_nolock
#endif
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());


std::vector<int> get_attachment(std::vector<int> source) {
	int n = (int)source.size();
	vector <int> ans;
	for(int i = 0; (1 << i) < n; i++){
		int x = 0;
		for(int j = 0; j < n; j++)if(j >> i & 1)x ^= source[j];
		ans.push_back(x);
	}
	int x = 0;
	for(int i = 0; i < n; i++)x ^= source[i];
	ans.push_back(x);
	return ans;
}

std::vector<int> retrieve(std::vector<int> data) {
	int n, num;
	if((int)data.size() >= 200)n = 255, num = 9;
	else n = 63, num = 7;
	int tmp = 0;
	for(int i = 0; i < n; i++)tmp ^= data[i];
	if(tmp == data[(int)data.size() - 1]){
		vector <int> ans;
		for(int i = 0; i < n; i++)ans.push_back(data[i]);
		return ans;
	}
	for(int i = 0; i < num - 1; i++){
		data[(int)data.size() - num + i] = !data[(int)data.size() - num + i];
		bool f = 1;
		for(int j = 0; (1 << j) < n; j++){
			int a = 0;
			for(int k = 0; k < n; k++)if(k >> j & 1)a ^= data[k];
			if(a != data[(int)data.size() - num + j])f = 0;
		}
		int a = 0;
		for(int j = 0; j < n; j++)a ^= data[j];
		if(a != data[(int)data.size() - 1])f = 0;
		if(f){
			vector <int> ans;
			for(int i = 0; i < n; i++)ans.push_back(data[i]);
			return ans;
		} 
		data[(int)data.size() - num + i] = !data[(int)data.size() - num + i];
	}
	int flipped = 0;
	for(int i = 0; (1 << i) < n; i++){
		int x = 0;
		for(int j = 0; j < n; j++)if(j >> i & 1)x ^= data[j];
		if(x != data[(int)data.size() - num + i])flipped ^= (1 << i);
	}
	data[flipped] = !data[flipped];
	vector <int> ans;
	for(int i = 0; i < n; i++)ans.push_back(data[i]);
	return ans;
}
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 1044 KB WA in grader: wrong source retrieval
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 32 ms 2504 KB WA in grader: wrong source retrieval
2 Halted 0 ms 0 KB -