Submission #151638

# Submission time Handle Problem Language Result Execution time Memory
151638 2019-09-04T02:00:18 Z cos18 King of Chairs (FXCUP4_chairs) C++17
Compilation error
0 ms 0 KB
#include "king.h"

long long SendInfo(std::vector<int> W, std::vector<int> C) {
	int N = W.size();
	return W[0]*100 + W[1]*10 + W[2]*1;
}
#include "vassal.h"
#include <algorithm>

long long BB;
int N;
std::vector<int> realC;

int find(int target, int start, int end){
	int location = (start+end)/2;
	if(target==realC[location]) return location;
	if(start==end){
		if(target>realC[location]) return location;
		return location-1;
	}
	if(target>realC[location]) return find(target, start, location-1);
	return find(target, location+1, end);
}

void Init(long long B, std::vector<int> C){
	N = C.size();
	realC = C;
	sort(realC.begin(), realC.end())
}

int Maid(int W){
	int location = find(W, 0, realC.size());
	if(location>=0){
		realC.erase(&realC[location]);
		return location;
	}
	return -1;
}

Compilation message

king.cpp: In function 'long long int SendInfo(std::vector<int>, std::vector<int>)':
king.cpp:4:6: warning: unused variable 'N' [-Wunused-variable]
  int N = W.size();
      ^

vassal.cpp: In function 'void Init(long long int, std::vector<int>)':
vassal.cpp:23:1: error: expected ';' before '}' token
 }
 ^
vassal.cpp: In function 'int Maid(int)':
vassal.cpp:28:31: error: no matching function for call to 'std::vector<int>::erase(__gnu_cxx::__alloc_traits<std::allocator<int> >::value_type*)'
   realC.erase(&realC[location]);
                               ^
In file included from /usr/include/c++/7/vector:64:0,
                 from vassal.h:2,
                 from vassal.cpp:1:
/usr/include/c++/7/bits/stl_vector.h:1179:7: note: candidate: std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::erase(std::vector<_Tp, _Alloc>::const_iterator) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::iterator = __gnu_cxx::__normal_iterator<int*, std::vector<int> >; typename std::_Vector_base<_Tp, _Alloc>::pointer = int*; std::vector<_Tp, _Alloc>::const_iterator = __gnu_cxx::__normal_iterator<const int*, std::vector<int> >; typename __gnu_cxx::__alloc_traits<typename std::_Vector_base<_Tp, _Alloc>::_Tp_alloc_type>::const_pointer = const int*]
       erase(const_iterator __position)
       ^~~~~
/usr/include/c++/7/bits/stl_vector.h:1179:7: note:   no known conversion for argument 1 from '__gnu_cxx::__alloc_traits<std::allocator<int> >::value_type* {aka int*}' to 'std::vector<int>::const_iterator {aka __gnu_cxx::__normal_iterator<const int*, std::vector<int> >}'
/usr/include/c++/7/bits/stl_vector.h:1206:7: note: candidate: std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::erase(std::vector<_Tp, _Alloc>::const_iterator, std::vector<_Tp, _Alloc>::const_iterator) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::iterator = __gnu_cxx::__normal_iterator<int*, std::vector<int> >; typename std::_Vector_base<_Tp, _Alloc>::pointer = int*; std::vector<_Tp, _Alloc>::const_iterator = __gnu_cxx::__normal_iterator<const int*, std::vector<int> >; typename __gnu_cxx::__alloc_traits<typename std::_Vector_base<_Tp, _Alloc>::_Tp_alloc_type>::const_pointer = const int*]
       erase(const_iterator __first, const_iterator __last)
       ^~~~~
/usr/include/c++/7/bits/stl_vector.h:1206:7: note:   candidate expects 2 arguments, 1 provided