제출 #784239

#제출 시각아이디문제언어결과실행 시간메모리
784239HD1Arranging Shoes (IOI19_shoes)C++14
컴파일 에러
0 ms0 KiB
//we are all lost trying to be someone.
#include "shoes.h"
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(0); cin.tie(0);
#define sz(x) ll(x.size())
#define reve(x) reverse(x.begin(),x.end())
#define ff first
#define ss second
#define pb push_back
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> ii;
typedef pair<ll, ii >tri;
const ll MAX=1e7+100;
const ll mod=1e9+7;
const ll inf=1e9;
vector<ll> z;
map<ll,ll>Mp;
ll cost(ll x, ll aux){
    ll ans=0;
    for(ll i=0; i<sz(z); i++){
        if(z[i]!=x)continue;
        ll pos=i;
        while(pos!=aux){
            pos--;
            swap(z[i],z[i-1]);
            ans++;
        }
        break;
    }
    return ans;
}
ll brute(vector<ll>s){
    ll ans=0;
    ll pos=0;
    for(ll i=0; i<sz(s); i++){
        ans+=cost(s[i]*-1,pos);
        pos++;
        ans+=cost(s[i],pos);
        pos++;
    }
}
long long count_swaps(vector<int> c){
    ll mn=1e18;
    do{
        z=c;
        mn=min(mn,brute(s));
    }while(next_permutation(c.begin()s.end()));
    return mn;
}

컴파일 시 표준 에러 (stderr) 메시지

shoes.cpp: In function 'll brute(std::vector<long long int>)':
shoes.cpp:43:1: warning: no return statement in function returning non-void [-Wreturn-type]
   43 | }
      | ^
shoes.cpp: In function 'long long int count_swaps(std::vector<int>)':
shoes.cpp:47:11: error: no match for 'operator=' (operand types are 'std::vector<long long int>' and 'std::vector<int>')
   47 |         z=c;
      |           ^
In file included from /usr/include/c++/10/vector:72,
                 from shoes.h:5,
                 from shoes.cpp:2:
/usr/include/c++/10/bits/vector.tcc:198:5: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(const std::vector<_Tp, _Alloc>&) [with _Tp = long long int; _Alloc = std::allocator<long long int>]'
  198 |     vector<_Tp, _Alloc>::
      |     ^~~~~~~~~~~~~~~~~~~
/usr/include/c++/10/bits/vector.tcc:199:42: note:   no known conversion for argument 1 from 'std::vector<int>' to 'const std::vector<long long int>&'
  199 |     operator=(const vector<_Tp, _Alloc>& __x)
      |               ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
In file included from /usr/include/c++/10/vector:67,
                 from shoes.h:5,
                 from shoes.cpp:2:
/usr/include/c++/10/bits/stl_vector.h:709:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::vector<_Tp, _Alloc>&&) [with _Tp = long long int; _Alloc = std::allocator<long long int>]'
  709 |       operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
      |       ^~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:709:26: note:   no known conversion for argument 1 from 'std::vector<int>' to 'std::vector<long long int>&&'
  709 |       operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
      |                 ~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_vector.h:730:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::initializer_list<_Tp>) [with _Tp = long long int; _Alloc = std::allocator<long long int>]'
  730 |       operator=(initializer_list<value_type> __l)
      |       ^~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:730:46: note:   no known conversion for argument 1 from 'std::vector<int>' to 'std::initializer_list<long long int>'
  730 |       operator=(initializer_list<value_type> __l)
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
shoes.cpp:48:25: error: 's' was not declared in this scope
   48 |         mn=min(mn,brute(s));
      |                         ^
shoes.cpp:49:38: error: expected ')' before 's'
   49 |     }while(next_permutation(c.begin()s.end()));
      |                            ~         ^
      |                                      )
shoes.cpp:49:45: error: no matching function for call to 'next_permutation(std::vector<int>::iterator)'
   49 |     }while(next_permutation(c.begin()s.end()));
      |                                             ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from shoes.cpp:3:
/usr/include/c++/10/bits/stl_algo.h:2971:5: note: candidate: 'template<class _BIter> bool std::next_permutation(_BIter, _BIter)'
 2971 |     next_permutation(_BidirectionalIterator __first,
      |     ^~~~~~~~~~~~~~~~
/usr/include/c++/10/bits/stl_algo.h:2971:5: note:   template argument deduction/substitution failed:
shoes.cpp:49:45: note:   candidate expects 2 arguments, 1 provided
   49 |     }while(next_permutation(c.begin()s.end()));
      |                                             ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from shoes.cpp:3:
/usr/include/c++/10/bits/stl_algo.h:3004:5: note: candidate: 'template<class _BIter, class _Compare> bool std::next_permutation(_BIter, _BIter, _Compare)'
 3004 |     next_permutation(_BidirectionalIterator __first,
      |     ^~~~~~~~~~~~~~~~
/usr/include/c++/10/bits/stl_algo.h:3004:5: note:   template argument deduction/substitution failed:
shoes.cpp:49:45: note:   candidate expects 3 arguments, 1 provided
   49 |     }while(next_permutation(c.begin()s.end()));
      |                                             ^