Submission #952382

# Submission time Handle Problem Language Result Execution time Memory
952382 2024-03-23T16:33:59 Z SmuggingSpun Data Transfer (IOI19_transfer) C++17
0 / 100
9 ms 4608 KB
#include "transfer.h"
#include<bits/stdc++.h>
using namespace std;
vector<int>get_attachment(vector<int>source){
	int BIT = (source.size() == 63 ? 6 : 8), x = 0, cnt_1 = 0;
	for(int i = 0; i < source.size(); i++){
		if(source[i] == 1){
			x ^= i + 1;
			cnt_1++;
		}
	}
	vector<int>data = source;
	for(int i = 0; i < BIT; i++){
		if(1 << i & x){
			data.emplace_back(1);
		}
		else{
			data.emplace_back(0);
		}
	}
	data.emplace_back(cnt_1 & 1);
	return data;
}
vector<int>retrieve(vector<int>data){
	int BIT = (data.size() == 70 ? 6 : 8), n = (BIT == 6 ? 63 : 255), sum_xor = 0, data_xor = 0, cnt_1 = 0;
	vector<int>ans(n);
	for(int i = 0; i < n; i++){
		if(data[i] == 1){
			sum_xor ^= i + 1;
			cnt_1++;
		}
		ans[i] = data[i];
	}
	for(int i = 0; i < BIT; i++){
		if(data[n + i] == 1){
			data_xor |= 1 << i;
		}
	}
	if(data_xor != sum_xor && (cnt_1 & 1) != data.back()){
		ans[(data_xor ^ sum_xor) - 1] ^= 1;
	}
	return ans;
}

Compilation message

transfer.cpp: In function 'std::vector<int> get_attachment(std::vector<int>)':
transfer.cpp:6:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    6 |  for(int i = 0; i < source.size(); i++){
      |                 ~~^~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 1048 KB WA in grader: wrong source retrieval
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 9 ms 4608 KB WA in grader: wrong source retrieval
2 Halted 0 ms 0 KB -