# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
143863 | Bodo171 | 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 "shoes.h"
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
const int nmax=200005;
vector<int> v[2][nmax];
struct pr
{
int x,y;
}a[nmax];
bool comp(pr unu,pr doi)
{
return (unu.x+unu.y<doi.x+doi.y);
}
int fin[nmax],po[nmax];
int nr,i,j,mn,col,poz;
int abss(int x)
{
if(x<0) return -x;
return x;
}
long long count_swaps(vector<int> s) {
int n=s.size();
n/=2;int ans=0;
for(int i=0;i<2*n;i++)
{
v[(s[i]>0)][abss(s[i])].push_back(i);
}
ans=0;
for(i=1;i<=n;i++)
{
for(j=0;j<v[0][i].size();j++)
{
a[nr++]={v[0][i][j],v[1][i][j]};
}
}
sort(a,a+nr,comp);
for(i=0;i<nr;i++)
{
fin[a[i].x]=2*i;
fin[a[i].y]=2*i+1;
}
sort(a+1,a+nr+1);
for(i=0;i<nr;i++)
for(j=i+1;j<nr;j++)
ans+=(fin[i]>fin[j]);
return ans;
}
Compilation message (stderr)
shoes.cpp: In function 'long long int count_swaps(std::vector<int>)': shoes.cpp:33:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] for(j=0;j<v[0][i].size();j++) ~^~~~~~~~~~~~~~~ shoes.cpp:45:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation] for(i=0;i<nr;i++) ^~~ shoes.cpp:48:2: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for' return ans; ^~~~~~ In file included from /usr/include/c++/7/bits/stl_algobase.h:71:0, from /usr/include/c++/7/vector:60, from shoes.h:5, from shoes.cpp:1: /usr/include/c++/7/bits/predefined_ops.h: In instantiation of 'constexpr bool __gnu_cxx::__ops::_Iter_less_iter::operator()(_Iterator1, _Iterator2) const [with _Iterator1 = pr*; _Iterator2 = pr*]': /usr/include/c++/7/bits/stl_algo.h:81:17: required from 'void std::__move_median_to_first(_Iterator, _Iterator, _Iterator, _Iterator, _Compare) [with _Iterator = pr*; _Compare = __gnu_cxx::__ops::_Iter_less_iter]' /usr/include/c++/7/bits/stl_algo.h:1921:34: required from '_RandomAccessIterator std::__unguarded_partition_pivot(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = pr*; _Compare = __gnu_cxx::__ops::_Iter_less_iter]' /usr/include/c++/7/bits/stl_algo.h:1953:38: required from 'void std::__introsort_loop(_RandomAccessIterator, _RandomAccessIterator, _Size, _Compare) [with _RandomAccessIterator = pr*; _Size = long int; _Compare = __gnu_cxx::__ops::_Iter_less_iter]' /usr/include/c++/7/bits/stl_algo.h:1968:25: required from 'void std::__sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = pr*; _Compare = __gnu_cxx::__ops::_Iter_less_iter]' /usr/include/c++/7/bits/stl_algo.h:4836:18: required from 'void std::sort(_RAIter, _RAIter) [with _RAIter = pr*]' shoes.cpp:44:20: required from here /usr/include/c++/7/bits/predefined_ops.h:43:23: error: no match for 'operator<' (operand types are 'pr' and 'pr') { return *__it1 < *__it2; } ~~~~~~~^~~~~~~~ In file included from /usr/include/c++/7/bits/stl_algobase.h:67:0, from /usr/include/c++/7/vector:60, from shoes.h:5, from shoes.cpp:1: /usr/include/c++/7/bits/stl_iterator.h:888:5: note: candidate: template<class _IteratorL, class _IteratorR, class _Container> bool __gnu_cxx::operator<(const __gnu_cxx::__normal_iterator<_IteratorL, _Container>&, const __gnu_cxx::__normal_iterator<_IteratorR, _Container>&) operator<(const __normal_iterator<_IteratorL, _Container>& __lhs, ^~~~~~~~ /usr/include/c++/7/bits/stl_iterator.h:888:5: note: template argument deduction/substitution failed: In file included from /usr/include/c++/7/bits/stl_algobase.h:71:0, from /usr/include/c++/7/vector:60, from shoes.h:5, from shoes.cpp:1: /usr/include/c++/7/bits/predefined_ops.h:43:23: note: 'pr' is not derived from 'const __gnu_cxx::__normal_iterator<_IteratorL, _Container>' { return *__it1 < *__it2; } ~~~~~~~^~~~~~~~ In file included from /usr/include/c++/7/bits/stl_algobase.h:67:0, from /usr/include/c++/7/vector:60, from shoes.h:5, from shoes.cpp:1: /usr/include/c++/7/bits/stl_iterator.h:895:5: note: candidate: template<class _Iterator, class _Container> bool __gnu_cxx::operator<(const __gnu_cxx::__normal_iterator<_Iterator, _Container>&, const __gnu_cxx::__normal_iterator<_Iterator, _Container>&) operator<(const __normal_iterator<_Iterator, _Container>& __lhs, ^~~~~~~~ /usr/include/c++/7/bits/stl_iterator.h:895:5: note: template argument deduction/substitution failed: In file included from /usr/include/c++/7/bits/stl_algobase.h:71:0, from /usr/include/c++/7/vector:60, from shoes.h:5, from shoes.cpp:1: /usr/include/c++/7/bits/predefined_ops.h:43:23: note: 'pr' is not derived from 'const __gnu_cxx::__normal_iterator<_Iterator, _Container>' { return *__it1 < *__it2; } ~~~~~~~^~~~~~~~ /usr/include/c++/7/bits/predefined_ops.h: In instantiation of 'bool __gnu_cxx::__ops::_Val_less_iter::operator()(_Value&, _Iterator) const [with _Value = pr; _Iterator = pr*]': /usr/include/c++/7/bits/stl_algo.h:1828:20: required from 'void std::__unguarded_linear_insert(_RandomAccessIterator, _Compare) [with _RandomAccessIterator = pr*; _Compare = __gnu_cxx::__ops::_Val_less_iter]' /usr/include/c++/7/bits/stl_algo.h:1855:36: required from 'void std::__insertion_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = pr*; _Compare = __gnu_cxx::__ops::_Iter_less_iter]' /usr/include/c++/7/bits/stl_algo.h:1885:25: required from 'void std::__final_insertion_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = pr*; _Compare = __gnu_cxx::__ops::_Iter_less_iter]' /usr/include/c++/7/bits/stl_algo.h:1971:31: required from 'void std::__sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = pr*; _Compare = __gnu_cxx::__ops::_Iter_less_iter]' /usr/include/c++/7/bits/stl_algo.h:4836:18: required from 'void std::sort(_RAIter, _RAIter) [with _RAIter = pr*]' shoes.cpp:44:20: required from here /usr/include/c++/7/bits/predefined_ops.h:90:22: error: no match for 'operator<' (operand types are 'pr' and 'pr') { return __val < *__it; } ~~~~~~^~~~~~~ In file included from /usr/include/c++/7/bits/stl_algobase.h:67:0, from /usr/include/c++/7/vector:60, from shoes.h:5, from shoes.cpp:1: /usr/include/c++/7/bits/stl_iterator.h:888:5: note: candidate: template<class _IteratorL, class _IteratorR, class _Container> bool __gnu_cxx::operator<(const __gnu_cxx::__normal_iterator<_IteratorL, _Container>&, const __gnu_cxx::__normal_iterator<_IteratorR, _Container>&) operator<(const __normal_iterator<_IteratorL, _Container>& __lhs, ^~~~~~~~ /usr/include/c++/7/bits/stl_iterator.h:888:5: note: template argument deduction/substitution failed: In file included from /usr/include/c++/7/bits/stl_algobase.h:71:0, from /usr/include/c++/7/vector:60, from shoes.h:5, from shoes.cpp:1: /usr/include/c++/7/bits/predefined_ops.h:90:22: note: 'pr' is not derived from 'const __gnu_cxx::__normal_iterator<_IteratorL, _Container>' { return __val < *__it; } ~~~~~~^~~~~~~ In file included from /usr/include/c++/7/bits/stl_algobase.h:67:0, from /usr/include/c++/7/vector:60, from shoes.h:5, from shoes.cpp:1: /usr/include/c++/7/bits/stl_iterator.h:895:5: note: candidate: template<class _Iterator, class _Container> bool __gnu_cxx::operator<(const __gnu_cxx::__normal_iterator<_Iterator, _Container>&, const __gnu_cxx::__normal_iterator<_Iterator, _Container>&) operator<(const __normal_iterator<_Iterator, _Container>& __lhs, ^~~~~~~~ /usr/include/c++/7/bits/stl_iterator.h:895:5: note: template argument deduction/substitution failed: In file included from /usr/include/c++/7/bits/stl_algobase.h:71:0, from /usr/include/c++/7/vector:60, from shoes.h:5, from shoes.cpp:1: /usr/include/c++/7/bits/predefined_ops.h:90:22: note: 'pr' is not derived from 'const __gnu_cxx::__normal_iterator<_Iterator, _Container>' { return __val < *__it; } ~~~~~~^~~~~~~ /usr/include/c++/7/bits/predefined_ops.h: In instantiation of 'bool __gnu_cxx::__ops::_Iter_less_val::operator()(_Iterator, _Value&) const [with _Iterator = pr*; _Value = pr]': /usr/include/c++/7/bits/stl_heap.h:133:48: required from 'void std::__push_heap(_RandomAccessIterator, _Distance, _Distance, _Tp, _Compare&) [with _RandomAccessIterator = pr*; _Distance = long int; _Tp = pr; _Compare = __gnu_cxx::__ops::_Iter_less_val]' /usr/include/c++/7/bits/stl_heap.h:237:23: required from 'void std::__adjust_heap(_RandomAccessIterator, _Distance, _Distance, _Tp, _Compare) [with _RandomAccessIterator = pr*; _Distance = long int; _Tp = pr; _Compare = __gnu_cxx::__ops::_Iter_less_iter]' /usr/include/c++/7/bits/stl_heap.h:342:22: required from 'void std::__make_heap(_RandomAccessIterator, _RandomAccessIterator, _Compare&) [with _RandomAccessIterator = pr*; _Compare = __gnu_cxx::__ops::_Iter_less_iter]' /usr/include/c++/7/bits/stl_algo.h:1672:23: required from 'void std::__heap_select(_RandomAccessIterator, _RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = pr*; _Compare = __gnu_cxx::__ops::_Iter_less_iter]' /usr/include/c++/7/bits/stl_algo.h:1933:25: required from 'void std::__partial_sort(_RandomAccessIterator, _RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = pr*; _Compare = __gnu_cxx::__ops::_Iter_less_iter]' /usr/include/c++/7/bits/stl_algo.h:1948:27: required from 'void std::__introsort_loop(_RandomAccessIterator, _RandomAccessIterator, _Size, _Compare) [with _RandomAccessIterator = pr*; _Size = long int; _Compare = __gnu_cxx::__ops::_Iter_less_iter]' /usr/include/c++/7/bits/stl_algo.h:1968:25: required from 'void std::__sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = pr*; _Compare = __gnu_cxx::__ops::_Iter_less_iter]' /usr/include/c++/7/bits/stl_algo.h:4836:18: required from 'void std::sort(_RAIter, _RAIter) [with _RAIter = pr*]' shoes.cpp:44:20: required from here /usr/include/c++/7/bits/predefined_ops.h:65:22: error: no match for 'operator<' (operand types are 'pr' and 'pr') { return *__it < __val; } ~~~~~~^~~~~~~ In file included from /usr/include/c++/7/bits/stl_algobase.h:67:0, from /usr/include/c++/7/vector:60, from shoes.h:5, from shoes.cpp:1: /usr/include/c++/7/bits/stl_iterator.h:888:5: note: candidate: template<class _IteratorL, class _IteratorR, class _Container> bool __gnu_cxx::operator<(const __gnu_cxx::__normal_iterator<_IteratorL, _Container>&, const __gnu_cxx::__normal_iterator<_IteratorR, _Container>&) operator<(const __normal_iterator<_IteratorL, _Container>& __lhs, ^~~~~~~~ /usr/include/c++/7/bits/stl_iterator.h:888:5: note: template argument deduction/substitution failed: In file included from /usr/include/c++/7/bits/stl_algobase.h:71:0, from /usr/include/c++/7/vector:60, from shoes.h:5, from shoes.cpp:1: /usr/include/c++/7/bits/predefined_ops.h:65:22: note: 'pr' is not derived from 'const __gnu_cxx::__normal_iterator<_IteratorL, _Container>' { return *__it < __val; } ~~~~~~^~~~~~~ In file included from /usr/include/c++/7/bits/stl_algobase.h:67:0, from /usr/include/c++/7/vector:60, from shoes.h:5, from shoes.cpp:1: /usr/include/c++/7/bits/stl_iterator.h:895:5: note: candidate: template<class _Iterator, class _Container> bool __gnu_cxx::operator<(const __gnu_cxx::__normal_iterator<_Iterator, _Container>&, const __gnu_cxx::__normal_iterator<_Iterator, _Container>&) operator<(const __normal_iterator<_Iterator, _Container>& __lhs, ^~~~~~~~ /usr/include/c++/7/bits/stl_iterator.h:895:5: note: template argument deduction/substitution failed: In file included from /usr/include/c++/7/bits/stl_algobase.h:71:0, from /usr/include/c++/7/vector:60, from shoes.h:5, from shoes.cpp:1: /usr/include/c++/7/bits/predefined_ops.h:65:22: note: 'pr' is not derived from 'const __gnu_cxx::__normal_iterator<_Iterator, _Container>' { return *__it < __val; } ~~~~~~^~~~~~~