Submission #1364052

#TimeUsernameProblemLanguageResultExecution timeMemory
1364052eliData Transfer (IOI19_transfer)C++20
0 / 100
3 ms1724 KiB
#include "transfer.h"
#include <bits/stdc++.h>
using namespace std;
#define out(x) #x<<" = "<<x<<" "
std::vector<int> get_attachment(std::vector<int> source) {
	vector<int> ans;
	//ans = source;
	int xorr = 0;
	for(int i = 0; i < 8; i++){
		xorr = 0;
		//cout<<out(i)<<endl;
		for(int j = 1; j <= source.size(); j++){
			if((j & (1<<i)) != 0){
				//cout<<out(j);
				xorr = xorr ^ source[j - 1];
			}
		}
		//cout<<endl;
		ans.push_back(xorr);
	}

	xorr = 0;
	for(int i = 0; i < ans.size(); i++){
		xorr = xorr ^ ans[i];
	}
	for(int i = 0; i < source.size(); i++) xorr = xorr ^ source[i];
	ans.push_back(xorr);
	return ans;
}

vector<int> retrieve(vector<int> data) {
	vector<int> ans;
	ans.clear();
	//cout<<data.size()<<endl;
	int xorr = 0;
	for(int i = 0; i < data.size() - 1; i++){
		xorr = xorr ^ data[i];
	}

	if(xorr == data[data.size() - 1]){

		for(int i = 0; i < data.size() - 9; i++) ans.push_back(data[i]);
		//cout<<ans.size()<<" "<<data.size()<<endl;
		return ans;
	}

	int curr = 0;
	for(int i = 0; i < 8; i++){
		xorr = 0;
		for(int j = 1; j <= data.size() - 9; j++){
			if((j & (1 <<i)) != 0) xorr = xorr ^ data[j - 1];
		}
		if(xorr != data[data.size() - 9 + i]){
			curr += (1<<i);
			//cout<<i<<" ";
		}
	}
	curr--;
	if(curr == -1){
		for(int i = 0; i < data.size() - 9; i++) ans.push_back(data[i]);
		//cout<<ans.size()<<" "<<data.size()<<endl;
		return ans;
	}
	data[curr] = (data[curr] + 1) % 2;

	bool ok = true;

	for(int i = 0; i < 8; i++){
		xorr = 0;
		for(int j = 1; j <= data.size() - 9; j++){
			if((j & (1 <<i)) != 0) xorr = xorr ^ data[j - 1];
		}
		if(xorr != data[data.size() - 9 + i]){
			
			ok = false;
			
		}
	}
	if(!ok) data[curr] = (data[curr] + 1) % 2;
	for(int i = 0; i < data.size() - 9; i++){
		ans.push_back(data[i]);
	}
	//cout<<ans.size()<<" "<<curr<<endl;
	return ans;
}

Compilation message (stderr)

grader.cpp: In instantiation of 'void shuffle(std::vector<T>&) [with T = Scenario]':
grader.cpp:200:10:   required from here
grader.cpp:28:23: warning: 'void std::random_shuffle(_RAIter, _RAIter) [with _RAIter = __gnu_cxx::__normal_iterator<Scenario*, vector<Scenario> >]' is deprecated: use 'std::shuffle' instead [-Wdeprecated-declarations]
   28 |         random_shuffle(v.begin(), v.end());
      |         ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/13/algorithm:61,
                 from grader.cpp:8:
/usr/include/c++/13/bits/stl_algo.h:4581:5: note: declared here
 4581 |     random_shuffle(_RandomAccessIterator __first, _RandomAccessIterator __last)
      |     ^~~~~~~~~~~~~~
#Result Execution timeMemoryGrader output
Fetching results...
#Result Execution timeMemoryGrader output
Fetching results...