Submission #1132255

#TimeUsernameProblemLanguageResultExecution timeMemory
1132255HappyCapybaraData Transfer (IOI19_transfer)C++20
0 / 100
3096 ms576 KiB
#include "transfer.h"
#include<bits/stdc++.h>
using namespace std;

int skib = 7;

int check(vector<int> code){
	int res = 0;
	for (int i=0; i<code.size(); i++){
		if (code[i]) res ^= (i+1);
		//cout << res << "\n";
	}
	return res;
}

vector<int> get_attachment(vector<int> source) {
	int cur = check(source);

	for (int i=0; i<(1<<skib); i++){
		vector<int> v(source.size(), 0);
		for (int j=0; j<skib; j++){
			if (i&(1<<j)) v.push_back(1);
			else v.push_back(0);
		}
		if ((check(v) ^ cur) == 0){
			vector<int> w;
			for (int j=0; j<skib; j++){
				if (i&(1<<j)) w.push_back(1);
				else w.push_back(0);
			}
			return w;
		}
	}
}

vector<int> retrieve(vector<int> data) {
	vector<int> w(data.begin(), data.end()-skib);
	//for (int x : w) cout << x << " ";
	//cout << "\n";
	if (check(data) == 0) return w;
	for (int i=0; i<data.size(); i++){
		data[i] = 1-data[i];
		vector<int> v(data.begin(), data.end()-skib);
		if (check(data) == 0) return v;
		data[i] = 1-data[i];
	}
}

Compilation message (stderr)

transfer.cpp: In function 'std::vector<int> get_attachment(std::vector<int>)':
transfer.cpp:34:1: warning: control reaches end of non-void function [-Wreturn-type]
   34 | }
      | ^
transfer.cpp: In function 'std::vector<int> retrieve(std::vector<int>)':
transfer.cpp:47:1: warning: control reaches end of non-void function [-Wreturn-type]
   47 | }
      | ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...