| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 282676 | medmdg | Arranging Shoes (IOI19_shoes) | C++14 | Compilation error | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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;
}
Compilation message (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