답안 #829572

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
829572 2023-08-18T12:57:08 Z MODDI Data Transfer (IOI19_transfer) C++14
컴파일 오류
0 ms 0 KB
#include "transfer.h"
std::vector<int> get_attachment(vector<int> source){
	int x = 0;
	vi ret = source;
	for(int i = 0; i < (int)source.size(); i++){
		if(source[i] == 1)
			x ^= (i+1);
	}
	int ones = 0;
	if(source.size() < 64){
		for(int i = 0; i < 6; i++){
			ret.pb(x&1);
			if(x&1) ones++;
			x >>=1;
		}
	}
	else
	{
		for(int i = 0; i < 8; i++){
			ret.pb(x&1);
			if(x&1) ones++;
			x>>=1;
		}
	}
	if(ones % 2 == 1)
		ret.pb(1);
	else
		ret.pb(0);
	return ret;
}
std::vector<int> retrieve(vector<int> data){
	int last = data.back();
	data.pop_back();
	int ac_last = 0, x = 0;
	if(data.size() < 71){
		for(int i = 0; i < 6; i++){
			x<<=1;
			x += data.back();
			if(data.back())	ac_last = 1 - ac_last;
			data.pop_back();
		}
	}
	else{
		for(int i = 0; i < 8; i++){
			x<<=1;
			x += data.back();
			if(data.back()) ac_last = 1 - ac_last;
			data.pop_back();
		}
	}
	if(ac_last != last)	return data;
	
	int ac_x = 0;
	for(int i = 0; i < (int)data.size(); i++){
		if(data[i]) ac_x ^= (i+1);
	}
	int error = ac_x ^ x;
	if(error == 0)	return data;
	
	data[error-1] = 1 - data[error-1];
	return data;
}

Compilation message

transfer.cpp:2:33: error: 'std::vector<int> get_attachment' redeclared as different kind of entity
    2 | std::vector<int> get_attachment(vector<int> source){
      |                                 ^~~~~~
In file included from transfer.cpp:1:
transfer.h:5:18: note: previous declaration 'std::vector<int> get_attachment(std::vector<int>)'
    5 | std::vector<int> get_attachment(std::vector<int> source);
      |                  ^~~~~~~~~~~~~~
transfer.cpp:2:33: error: 'vector' was not declared in this scope; did you mean 'std::vector'?
    2 | std::vector<int> get_attachment(vector<int> source){
      |                                 ^~~~~~
      |                                 std::vector
In file included from /usr/include/c++/10/vector:67,
                 from transfer.h:3,
                 from transfer.cpp:1:
/usr/include/c++/10/bits/stl_vector.h:389:11: note: 'std::vector' declared here
  389 |     class vector : protected _Vector_base<_Tp, _Alloc>
      |           ^~~~~~
transfer.cpp:2:40: error: expected primary-expression before 'int'
    2 | std::vector<int> get_attachment(vector<int> source){
      |                                        ^~~
transfer.cpp:31:27: error: 'std::vector<int> retrieve' redeclared as different kind of entity
   31 | std::vector<int> retrieve(vector<int> data){
      |                           ^~~~~~
In file included from transfer.cpp:1:
transfer.h:6:18: note: previous declaration 'std::vector<int> retrieve(std::vector<int>)'
    6 | std::vector<int> retrieve(std::vector<int> data);
      |                  ^~~~~~~~
transfer.cpp:31:27: error: 'vector' was not declared in this scope; did you mean 'std::vector'?
   31 | std::vector<int> retrieve(vector<int> data){
      |                           ^~~~~~
      |                           std::vector
In file included from /usr/include/c++/10/vector:67,
                 from transfer.h:3,
                 from transfer.cpp:1:
/usr/include/c++/10/bits/stl_vector.h:389:11: note: 'std::vector' declared here
  389 |     class vector : protected _Vector_base<_Tp, _Alloc>
      |           ^~~~~~
transfer.cpp:31:34: error: expected primary-expression before 'int'
   31 | std::vector<int> retrieve(vector<int> data){
      |                                  ^~~