Submission #770876

# Submission time Handle Problem Language Result Execution time Memory
770876 2023-07-02T05:32:58 Z rxlfd314 Data Transfer (IOI19_transfer) C++17
0 / 100
5 ms 3008 KB
#include "transfer.h"
#include <bits/stdc++.h>
using namespace std;

static int N;

void yeet(vector<int> &v, vector<int> &source) {
	for (int j = 0; (1 << j) < N; j++) {
		v.push_back(0);
		for (int i = 0; i < N; i++) {
			if (i & 1 << j) {
				v[j] ^= source[i];
			}
		}
	}
}

vector<int> get_attachment(vector<int> source) {
	N = source.size();
	vector<int> ret;
	yeet(ret, source);
	ret.push_back(0);
	for (int i = 0; i < N; i++) {
		ret.back() ^= source[i];
	}
	return ret;
}

vector<int> retrieve(vector<int> data) {
	int M = data.size();
	vector<int> test;
	yeet(test, data);
	if (test == vector<int>(data.begin()+N, data.begin()+M-1)) {
		return vector<int>(data.begin(), data.begin()+N);
	}
	bool p = 0;
	for (int i = 0; i < N; i++) {
		p ^= data[i];
	}
	if (p ^ data[M-1]) {
		for (int i = 0; i < N; i++) {
			test.clear();
			data[i] ^= 1;
			yeet(test, data);
			if (test == vector<int>(data.begin()+N, data.begin()+M-1)) {
				return vector<int>(data.begin(), data.begin()+N);
			}
			data[i] ^= 1;
		}
	} else {
		return vector<int>(data.begin(), data.begin()+N);
	}
}

Compilation message

transfer.cpp: In function 'std::vector<int> retrieve(std::vector<int>)':
transfer.cpp:31:14: warning: control reaches end of non-void function [-Wreturn-type]
   31 |  vector<int> test;
      |              ^~~~
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 992 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 5 ms 3008 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -