Submission #1132253

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

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

vector<int> get_attachment(vector<int> source) {
	for (int i=0; i<(1<<9); i++){
		vector<int> v = source;
		for (int j=0; j<9; j++){
			if (i&(1<<j)) v.push_back(1);
			else v.push_back(0);
		}
		/*cout << "i: " << i << "\n";
		for (int x : v) cout << x << " ";
		cout << "\n";*/
		if (check(v)){
			vector<int> w;
			for (int j=0; j<9; 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()-9);
	//for (int x : w) cout << x << " ";
	//cout << "\n";
	if (check(data)) return w;
	for (int i=0; i<data.size(); i++){
		data[i] = 1-data[i];
		vector<int> v(data.begin(), data.end()-9);
		if (check(data)) 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...