Submission #1047367

#TimeUsernameProblemLanguageResultExecution timeMemory
1047367vjudge1Arranging Shoes (IOI19_shoes)C++17
Compilation error
0 ms0 KiB
#pragma GCC optimize("unroll-loops,Ofast,O3")
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define spc << " " <<
#define endl "\n"
#define all(x) x.begin(), x.end()
#define int long long
#define ii pair<long long,int>
#define vi vector<int>
#define vii vector<ii>
#define st first
#define nd second
#define mid (l+r)/2
#define inf 1e15
#define MOD 1000000007
#define MX 300005
using namespace std;

int count_swaps(vi S){
    int n=sizeof(S)/sizeof(*S);
    n/=2;
    int arr[2*n+1];
    for(int i=0; i<2*n; i++) arr[i+1]=S[i];
    map<int, vi> heh;
    for(int i=1; i<=2*n; i++){
        heh[arr[i]].pb(i);
    }
    queue<int> cnt[2*n+1];
    int wow=0;
    set<int> s;
    for(int i=1; i<=2*n; i++){
        if(cnt[n-arr[i]].size()){
            wow+=s.size()-distance(s.begin(), s.upper_bound(cnt[n-arr[i]].front()));
            s.erase(cnt[n-arr[i]].front());
            cnt[n-arr[i]].pop();
            continue;
        }
        s.insert(i);
        cnt[n+arr[i]].push(i);
    }
    int ans=0;
    for(auto p:heh){
        if(p.st>=0) break;
        for(int i=0; i<p.nd.size(); i++){
            ans+=abs(heh[-p.st][i] - p.nd[i]) - 1;
            if(heh[-p.st][i]<p.nd[i]) ans++;
        }
    }
    return ans-wow;
}
 
 
/*signed main(){
    ios_base::sync_with_stdio(false);cin.tie(0);
    #ifdef Local
    freopen("in","r",stdin);
    freopen("out","w",stdout);
    #endif
 
    /*freopen("nondec.in","r",stdin);
    freopen("nondec.out","w",stdout);*
 
    int t=1;
    //cin >> t;
    //while(t--) solve();
    int n; cin >> n;
    vi nop(2*n;
    for(int i=0; i<2*n; i++) cin >> nop[i];
    cout << count_swaps(nop) << endl;
}*/

Compilation message (stderr)

shoes.cpp:61:5: warning: "/*" within comment [-Wcomment]
   61 |     /*freopen("nondec.in","r",stdin);
      |      
shoes.cpp: In function 'long long int count_swaps(std::vector<long long int>)':
shoes.cpp:21:28: error: no match for 'operator*' (operand type is 'std::vector<long long int>')
   21 |     int n=sizeof(S)/sizeof(*S);
      |                            ^~
In file included from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from shoes.cpp:2:
/usr/include/c++/10/complex:391:5: note: candidate: 'template<class _Tp> std::complex<_Tp> std::operator*(const std::complex<_Tp>&, const std::complex<_Tp>&)'
  391 |     operator*(const complex<_Tp>& __x, const complex<_Tp>& __y)
      |     ^~~~~~~~
/usr/include/c++/10/complex:391:5: note:   template argument deduction/substitution failed:
shoes.cpp:21:29: note:   'std::vector<long long int>' is not derived from 'const std::complex<_Tp>'
   21 |     int n=sizeof(S)/sizeof(*S);
      |                             ^
In file included from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from shoes.cpp:2:
/usr/include/c++/10/complex:400:5: note: candidate: 'template<class _Tp> std::complex<_Tp> std::operator*(const std::complex<_Tp>&, const _Tp&)'
  400 |     operator*(const complex<_Tp>& __x, const _Tp& __y)
      |     ^~~~~~~~
/usr/include/c++/10/complex:400:5: note:   template argument deduction/substitution failed:
shoes.cpp:21:29: note:   'std::vector<long long int>' is not derived from 'const std::complex<_Tp>'
   21 |     int n=sizeof(S)/sizeof(*S);
      |                             ^
In file included from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from shoes.cpp:2:
/usr/include/c++/10/complex:409:5: note: candidate: 'template<class _Tp> std::complex<_Tp> std::operator*(const _Tp&, const std::complex<_Tp>&)'
  409 |     operator*(const _Tp& __x, const complex<_Tp>& __y)
      |     ^~~~~~~~
/usr/include/c++/10/complex:409:5: note:   template argument deduction/substitution failed:
shoes.cpp:21:29: note:   candidate expects 2 arguments, 1 provided
   21 |     int n=sizeof(S)/sizeof(*S);
      |                             ^
In file included from /usr/include/c++/10/valarray:603,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:95,
                 from shoes.cpp:2:
/usr/include/c++/10/bits/valarray_after.h:407:5: note: candidate: 'template<class _Dom1, class _Dom2> std::_Expr<std::__detail::_BinClos<std::__multiplies, std::_Expr, std::_Expr, _Dom1, _Dom2>, typename std::__fun<std::__multiplies, typename _Dom1::value_type>::result_type> std::operator*(const std::_Expr<_Dom1, typename _Dom1::value_type>&, const std::_Expr<_Dom2, typename _Dom2::value_type>&)'
  407 |     _DEFINE_EXPR_BINARY_OPERATOR(*, __multiplies)
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/10/bits/valarray_after.h:407:5: note:   template argument deduction/substitution failed:
shoes.cpp:21:29: note:   'std::vector<long long int>' is not derived from 'const std::_Expr<_Dom1, typename _Dom1::value_type>'
   21 |     int n=sizeof(S)/sizeof(*S);
      |                             ^
In file included from /usr/include/c++/10/valarray:603,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:95,
                 from shoes.cpp:2:
/usr/include/c++/10/bits/valarray_after.h:407:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__multiplies, std::_Expr, std::_Constant, _Dom, typename _Dom::value_type>, typename std::__fun<std::__multiplies, typename _Dom1::value_type>::result_type> std::operator*(const std::_Expr<_Dom1, typename _Dom1::value_type>&, const typename _Dom::value_type&)'
  407 |     _DEFINE_EXPR_BINARY_OPERATOR(*, __multiplies)
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/10/bits/valarray_after.h:407:5: note:   template argument deduction/substitution failed:
shoes.cpp:21:29: note:   'std::vector<long long int>' is not derived from 'const std::_Expr<_Dom1, typename _Dom1::value_type>'
   21 |     int n=sizeof(S)/sizeof(*S);
      |                             ^
In file included from /usr/include/c++/10/valarray:603,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:95,
                 from shoes.cpp:2:
/usr/include/c++/10/bits/valarray_after.h:407:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__multiplies, std::_Constant, std::_Expr, typename _Dom::value_type, _Dom>, typename std::__fun<std::__multiplies, typename _Dom1::value_type>::result_type> std::operator*(const typename _Dom::value_type&, const std::_Expr<_Dom1, typename _Dom1::value_type>&)'
  407 |     _DEFINE_EXPR_BINARY_OPERATOR(*, __multiplies)
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/10/bits/valarray_after.h:407:5: note:   template argument deduction/substitution failed:
shoes.cpp:21:29: note:   candidate expects 2 arguments, 1 provided
   21 |     int n=sizeof(S)/sizeof(*S);
      |                             ^
In file included from /usr/include/c++/10/valarray:603,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:95,
                 from shoes.cpp:2:
/usr/include/c++/10/bits/valarray_after.h:407:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__multiplies, std::_Expr, std::_ValArray, _Dom, typename _Dom::value_type>, typename std::__fun<std::__multiplies, typename _Dom1::value_type>::result_type> std::operator*(const std::_Expr<_Dom1, typename _Dom1::value_type>&, const std::valarray<typename _Dom::value_type>&)'
  407 |     _DEFINE_EXPR_BINARY_OPERATOR(*, __multiplies)
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/10/bits/valarray_after.h:407:5: note:   template argument deduction/substitution failed:
shoes.cpp:21:29: note:   'std::vector<long long int>' is not derived from 'const std::_Expr<_Dom1, typename _Dom1::value_type>'
   21 |     int n=sizeof(S)/sizeof(*S);
      |                             ^
In file included from /usr/include/c++/10/valarray:603,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:95,
                 from shoes.cpp:2:
/usr/include/c++/10/bits/valarray_after.h:407:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__multiplies, std::_ValArray, std::_Expr, typename _Dom::value_type, _Dom>, typename std::__fun<std::__multiplies, typename _Dom1::value_type>::result_type> std::operator*(const std::valarray<typename _Dom::value_type>&, const std::_Expr<_Dom1, typename _Dom1::value_type>&)'
  407 |     _DEFINE_EXPR_BINARY_OPERATOR(*, __multiplies)
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/10/bits/valarray_after.h:407:5: note:   template argument deduction/substitution failed:
shoes.cpp:21:29: note:   candidate expects 2 arguments, 1 provided
   21 |     int n=sizeof(S)/sizeof(*S);
      |                             ^
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:95,
                 from shoes.cpp:2:
/usr/include/c++/10/valarray:1187:1: note: candidate: 'template<class _Tp> std::_Expr<std::__detail::_BinClos<std::__multiplies, std::_ValArray, std::_ValArray, _Tp, _Tp>, typename std::__fun<std::__multiplies, _Tp>::result_type> std::operator*(const std::valarray<_Tp>&, const std::valarray<_Tp>&)'
 1187 | _DEFINE_BINARY_OPERATOR(*, __multiplies)
      | ^~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/10/valarray:1187:1: note:   template argument deduction/substitution failed:
shoes.cpp:21:29: note:   'std::vector<long long int>' is not derived from 'const std::valarray<_Tp>'
   21 |     int n=sizeof(S)/sizeof(*S);
      |                             ^
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:95,
                 from shoes.cpp:2:
/usr/include/c++/10/valarray:1187:1: note: candidate: 'template<class _Tp> std::_Expr<std::__detail::_BinClos<std::__multiplies, std::_ValArray, std::_Constant, _Tp, _Tp>, typename std::__fun<std::__multiplies, _Tp>::result_type> std::operator*(const std::valarray<_Tp>&, const typename std::valarray<_Tp>::value_type&)'
 1187 | _DEFINE_BINARY_OPERATOR(*, __multiplies)
      | ^~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/10/valarray:1187:1: note:   template argument deduction/substitution failed:
shoes.cpp:21:29: note:   'std::vector<long long int>' is not derived from 'const std::valarray<_Tp>'
   21 |     int n=sizeof(S)/sizeof(*S);
      |                             ^
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:95,
                 from shoes.cpp:2:
/usr/include/c++/10/valarray:1187:1: note: candidate: 'template<class _Tp> std::_Expr<std::__detail::_BinClos<std::__multiplies, std::_Constant, std::_ValArray, _Tp, _Tp>, typename std::__fun<std::__multiplies, _Tp>::result_type> std::operator*(const typename std::valarray<_Tp>::value_type&, const std::valarray<_Tp>&)'
 1187 | _DEFINE_BINARY_OPERATOR(*, __multiplies)
      | ^~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/10/valarray:1187:1: note:   template argument deduction/substitution failed:
shoes.cpp:21:29: note:   candidate expects 2 arguments, 1 provided
   21 |     int n=sizeof(S)/sizeof(*S);
      |                             ^
shoes.cpp:45:23: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   45 |         for(int i=0; i<p.nd.size(); i++){
      |                      ~^~~~~~~~~~~~