Submission #1308696

#TimeUsernameProblemLanguageResultExecution timeMemory
1308696AMel0nData Transfer (IOI19_transfer)C++20
60 / 100
4 ms1720 KiB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
#define FOR(i, N) for(int i = 0; i < N; i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second

#include "transfer.h"

std::vector<int> get_attachment(std::vector<int> source) {
	vector<int> res;
	int N = source.size();
	int parity = 0;
	int xor1 = 0;
	FOR(i, N) {
		if (source[i]) xor1 ^= (i+1);
		parity = (parity + source[i]) % 2;
	}
	res.push_back(parity);
	FOR(mask, 6) {
		if (xor1 & (1 << (5-mask))) res.push_back(1);
		else res.push_back(0);
	}
	return res;
}

std::vector<int> retrieve(std::vector<int> data) {
	int N = data.size() - 7;
	int xor1 = 0, xor2 = 0;
	FOR(mask, 6) {
		if (data[data.size()-1-mask]) xor1 += (1 << mask);
	}
	int parity = data[data.size() - 7];
	int parity2 = 0;
	FOR(i, N) {
		if (data[i]) xor2 ^= (i+1);
		parity2 = (parity2 + data[i]) % 2;
	}
	vector<int> res;
	if (parity == parity2) {
		FOR(i, N) res.push_back(data[i]);
	} else {
		FOR(i, N) {
			if ((xor1 ^ xor2) - 1 == i) res.push_back(1 - data[i]);
			else res.push_back(data[i]);
		}
	}
	return res;
}

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)
      |     ^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...