답안 #829569

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
829569 2023-08-18T12:56:19 Z Blagoj Data Transfer (IOI19_transfer) C++17
0 / 100
6 ms 5360 KB
#include <bits/stdc++.h>
#include "transfer.h"
// #include "grader.cpp"

using namespace std;

vector<int> get_attachment(vector<int> source) {
	int n = source.size();
	vector<int> extra;
	for (int i = 0; i < (n == 63 ? 6 : 8); i++) {
		int sum = 0;
		for (int j = 1; j <= n; j++) {
			if (j && (1 << i)) {
				sum ^= source[j - 1];
			}
		}
		extra.push_back(sum);
		source.push_back(sum);
	}
	int last = 0;
	for (auto x : extra) last ^= x;
	source.push_back(last);
	return {source};
}

vector<int> retrieve(vector<int> data) {
	vector<int> extra;
	for (int i = data.size() - 1; (i >= 62 && i <= 70) || (i >= 254 && i <= 300); i--) extra.push_back(data[i]);
	reverse(extra.begin(), extra.end());
	int Xor = 0;
	for (int i = 0; i < extra.size() - 1; i++) Xor ^= extra[i];
	if (Xor != extra.back()) return vector<int>(data.begin(), data.end() - extra.size());
	int num = 0;
	for (int i = 0; i < (data.size() - extra.size() == 63 ? 7 : 9); i++) {
		int sum = 0;
		for (int j = 1; j <= data.size() - extra.size(); j++) {
			if (j && (1 << i)) {
				sum ^= data[j - 1];
			}
		}
		num |= (1 << i) * sum;
	}
	int cur = 0;
	for (int i = 0; i < extra.size(); i++) cur |= (1 << i) * extra[i];
	int pos = num ^ cur;
	data[pos] = !data[pos];
	return vector<int>(data.begin(), data.end() - extra.size());
}

Compilation message

transfer.cpp: In function 'std::vector<int> get_attachment(std::vector<int>)':
transfer.cpp:13:16: warning: '<<' in boolean context, did you mean '<'? [-Wint-in-bool-context]
   13 |    if (j && (1 << i)) {
      |             ~~~^~~~~
transfer.cpp: In function 'std::vector<int> retrieve(std::vector<int>)':
transfer.cpp:31:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |  for (int i = 0; i < extra.size() - 1; i++) Xor ^= extra[i];
      |                  ~~^~~~~~~~~~~~~~~~~~
transfer.cpp:36:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |   for (int j = 1; j <= data.size() - extra.size(); j++) {
      |                   ~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
transfer.cpp:37:16: warning: '<<' in boolean context, did you mean '<'? [-Wint-in-bool-context]
   37 |    if (j && (1 << i)) {
      |             ~~~^~~~~
transfer.cpp:44:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   44 |  for (int i = 0; i < extra.size(); i++) cur |= (1 << i) * extra[i];
      |                  ~~^~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 1292 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 6 ms 5360 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -