# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
282676 | medmdg | Arranging Shoes (IOI19_shoes) | C++14 | 컴파일 에러 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
long long count_swaps(std::vector<int> S){
int ans=0;
int count=0;
while(S.size()){
if(S[0]>0)
count ++;
for(int i=1;i<S.size();i++){
if(S[i]==-1*S[0]){
count += i-1;
S.erase(i);
S.erase(0);
break;
}
}
ans+=count;
}
return ans;
}
컴파일 시 표준 에러 (stderr) 메시지
shoes.cpp: In function 'long long int count_swaps(std::vector<int>)': shoes.cpp:10:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare] 10 | for(int i=1;i<S.size();i++){ | ~^~~~~~~~~ shoes.cpp:13:26: error: no matching function for call to 'std::vector<int>::erase(int&)' 13 | S.erase(i); | ^ In file included from /usr/include/c++/9/vector:67, from /usr/include/c++/9/queue:61, from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:86, from shoes.cpp:1: /usr/include/c++/9/bits/stl_vector.h:1427: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*]' 1427 | erase(const_iterator __position) | ^~~~~ /usr/include/c++/9/bits/stl_vector.h:1427:28: note: no known conversion for argument 1 from 'int' to 'std::vector<int>::const_iterator' {aka '__gnu_cxx::__normal_iterator<const int*, std::vector<int> >'} 1427 | erase(const_iterator __position) | ~~~~~~~~~~~~~~~^~~~~~~~~~ /usr/include/c++/9/bits/stl_vector.h:1454: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*]' 1454 | erase(const_iterator __first, const_iterator __last) | ^~~~~ /usr/include/c++/9/bits/stl_vector.h:1454:7: note: candidate expects 2 arguments, 1 provided shoes.cpp:14:26: error: no matching function for call to 'std::vector<int>::erase(int)' 14 | S.erase(0); | ^ In file included from /usr/include/c++/9/vector:67, from /usr/include/c++/9/queue:61, from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:86, from shoes.cpp:1: /usr/include/c++/9/bits/stl_vector.h:1427: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*]' 1427 | erase(const_iterator __position) | ^~~~~ /usr/include/c++/9/bits/stl_vector.h:1427:28: note: no known conversion for argument 1 from 'int' to 'std::vector<int>::const_iterator' {aka '__gnu_cxx::__normal_iterator<const int*, std::vector<int> >'} 1427 | erase(const_iterator __position) | ~~~~~~~~~~~~~~~^~~~~~~~~~ /usr/include/c++/9/bits/stl_vector.h:1454: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*]' 1454 | erase(const_iterator __first, const_iterator __last) | ^~~~~ /usr/include/c++/9/bits/stl_vector.h:1454:7: note: candidate expects 2 arguments, 1 provided