Submission #155985

#TimeUsernameProblemLanguageResultExecution timeMemory
155985giorgikobArranging Shoes (IOI19_shoes)C++14
Compilation error
0 ms0 KiB
#include "shoes.h" int n,r,pos; long long ans; std::vector<int>locl[500001],locr[500001],indl[500001],indr[500001]; int tree[500001]; void upd(int node,int tl,int tr){ if(tl==tr){ tree[node] = 1; return; } int mid = (tl+tr)/2; if(pos<mid) upd(node*2,tl,mid); else upd(node*2+1,mid+1,tr); tree[node] = tree[node*2] + tree[node*2+1]; } int get(int node,int tl,int tr){ if(r<tl)return 0; if(tr<=r)return tree[node]; int mid = (tr+tl)/2; int x = get(node*2,tl,mid); int y = get(node*2+1,mid+1,tr); return x+y; } long long count_swaps(std::vector<int> s) { n = s.size(); for(int i=0;i<n;i++){ if(s[i]<0){ locl[-s[i]] = i; } else { locr[s[i]] = i; } } for(int i=0;i<n;i++){ if(s[i]<0){ int loc = locr[ s[i] ][ indr[ s[i] ] ]; r = loc; ans += loc - i - get(1,0,n-1); indr[ s[i] ] ++; pos = loc; upd(1,0,n-1); } else { int loc = locl[ s[i] ][ indl[ s[i] ] ]; r = loc; ans += loc - i + 1 - get(1,0,n-1); indl[ s[i] ] ++; pos = loc; upd(1,0,n-1); } } return ans; }

Compilation message (stderr)

shoes.cpp: In function 'long long int count_swaps(std::vector<int>)':
shoes.cpp:48:18: error: no match for 'operator=' (operand types are 'std::vector<int>' and 'int')
    locl[-s[i]] = i;
                  ^
In file included from /usr/include/c++/7/vector:69:0,
                 from shoes.h:5,
                 from shoes.cpp:1:
/usr/include/c++/7/bits/vector.tcc:179:5: note: candidate: std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(const std::vector<_Tp, _Alloc>&) [with _Tp = int; _Alloc = std::allocator<int>]
     vector<_Tp, _Alloc>::
     ^~~~~~~~~~~~~~~~~~~
/usr/include/c++/7/bits/vector.tcc:179:5: note:   no known conversion for argument 1 from 'int' to 'const std::vector<int>&'
In file included from /usr/include/c++/7/vector:64:0,
                 from shoes.h:5,
                 from shoes.cpp:1:
/usr/include/c++/7/bits/stl_vector.h:461:7: note: candidate: std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::vector<_Tp, _Alloc>&&) [with _Tp = int; _Alloc = std::allocator<int>]
       operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
       ^~~~~~~~
/usr/include/c++/7/bits/stl_vector.h:461:7: note:   no known conversion for argument 1 from 'int' to 'std::vector<int>&&'
/usr/include/c++/7/bits/stl_vector.h:482:7: note: candidate: std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::initializer_list<_Tp>) [with _Tp = int; _Alloc = std::allocator<int>]
       operator=(initializer_list<value_type> __l)
       ^~~~~~~~
/usr/include/c++/7/bits/stl_vector.h:482:7: note:   no known conversion for argument 1 from 'int' to 'std::initializer_list<int>'
shoes.cpp:50:17: error: no match for 'operator=' (operand types are 'std::vector<int>' and 'int')
    locr[s[i]] = i;
                 ^
In file included from /usr/include/c++/7/vector:69:0,
                 from shoes.h:5,
                 from shoes.cpp:1:
/usr/include/c++/7/bits/vector.tcc:179:5: note: candidate: std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(const std::vector<_Tp, _Alloc>&) [with _Tp = int; _Alloc = std::allocator<int>]
     vector<_Tp, _Alloc>::
     ^~~~~~~~~~~~~~~~~~~
/usr/include/c++/7/bits/vector.tcc:179:5: note:   no known conversion for argument 1 from 'int' to 'const std::vector<int>&'
In file included from /usr/include/c++/7/vector:64:0,
                 from shoes.h:5,
                 from shoes.cpp:1:
/usr/include/c++/7/bits/stl_vector.h:461:7: note: candidate: std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::vector<_Tp, _Alloc>&&) [with _Tp = int; _Alloc = std::allocator<int>]
       operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
       ^~~~~~~~
/usr/include/c++/7/bits/stl_vector.h:461:7: note:   no known conversion for argument 1 from 'int' to 'std::vector<int>&&'
/usr/include/c++/7/bits/stl_vector.h:482:7: note: candidate: std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::initializer_list<_Tp>) [with _Tp = int; _Alloc = std::allocator<int>]
       operator=(initializer_list<value_type> __l)
       ^~~~~~~~
/usr/include/c++/7/bits/stl_vector.h:482:7: note:   no known conversion for argument 1 from 'int' to 'std::initializer_list<int>'
shoes.cpp:56:26: error: no match for 'operator[]' (operand types are 'std::vector<int>' and 'std::vector<int>')
    int loc = locr[ s[i] ][ indr[ s[i] ] ];
                          ^
In file included from /usr/include/c++/7/vector:64:0,
                 from shoes.h:5,
                 from shoes.cpp:1:
/usr/include/c++/7/bits/stl_vector.h:795:7: note: candidate: std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::operator[](std::vector<_Tp, _Alloc>::size_type) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::reference = int&; std::vector<_Tp, _Alloc>::size_type = long unsigned int]
       operator[](size_type __n) _GLIBCXX_NOEXCEPT
       ^~~~~~~~
/usr/include/c++/7/bits/stl_vector.h:795:7: note:   no known conversion for argument 1 from 'std::vector<int>' to 'std::vector<int>::size_type {aka long unsigned int}'
/usr/include/c++/7/bits/stl_vector.h:813:7: note: candidate: std::vector<_Tp, _Alloc>::const_reference std::vector<_Tp, _Alloc>::operator[](std::vector<_Tp, _Alloc>::size_type) const [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::const_reference = const int&; std::vector<_Tp, _Alloc>::size_type = long unsigned int]
       operator[](size_type __n) const _GLIBCXX_NOEXCEPT
       ^~~~~~~~
/usr/include/c++/7/bits/stl_vector.h:813:7: note:   no known conversion for argument 1 from 'std::vector<int>' to 'std::vector<int>::size_type {aka long unsigned int}'
shoes.cpp:59:17: error: no 'operator++(int)' declared for postfix '++' [-fpermissive]
    indr[ s[i] ] ++;
    ~~~~~~~~~~~~~^~
shoes.cpp:64:26: error: no match for 'operator[]' (operand types are 'std::vector<int>' and 'std::vector<int>')
    int loc = locl[ s[i] ][ indl[ s[i] ] ];
                          ^
In file included from /usr/include/c++/7/vector:64:0,
                 from shoes.h:5,
                 from shoes.cpp:1:
/usr/include/c++/7/bits/stl_vector.h:795:7: note: candidate: std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::operator[](std::vector<_Tp, _Alloc>::size_type) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::reference = int&; std::vector<_Tp, _Alloc>::size_type = long unsigned int]
       operator[](size_type __n) _GLIBCXX_NOEXCEPT
       ^~~~~~~~
/usr/include/c++/7/bits/stl_vector.h:795:7: note:   no known conversion for argument 1 from 'std::vector<int>' to 'std::vector<int>::size_type {aka long unsigned int}'
/usr/include/c++/7/bits/stl_vector.h:813:7: note: candidate: std::vector<_Tp, _Alloc>::const_reference std::vector<_Tp, _Alloc>::operator[](std::vector<_Tp, _Alloc>::size_type) const [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::const_reference = const int&; std::vector<_Tp, _Alloc>::size_type = long unsigned int]
       operator[](size_type __n) const _GLIBCXX_NOEXCEPT
       ^~~~~~~~
/usr/include/c++/7/bits/stl_vector.h:813:7: note:   no known conversion for argument 1 from 'std::vector<int>' to 'std::vector<int>::size_type {aka long unsigned int}'
shoes.cpp:67:17: error: no 'operator++(int)' declared for postfix '++' [-fpermissive]
    indl[ s[i] ] ++;
    ~~~~~~~~~~~~~^~