답안 #952377

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
952377 2024-03-23T16:26:55 Z SmuggingSpun Data Transfer (IOI19_transfer) C++14
0 / 100
7 ms 4620 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++){
      |                 ~~^~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 1044 KB WA in grader: wrong source retrieval
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 7 ms 4620 KB WA in grader: wrong source retrieval
2 Halted 0 ms 0 KB -