제출 #784243

#제출 시각아이디문제언어결과실행 시간메모리
784243HD1Arranging 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,s;
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(){
    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++;
    }
    return ans;
}
long long count_swaps(vector<int> c){
    ll mn=1e18;
    for(ll i=2; i<=sz(c); i+=2){
        s.push_back(i/2);
    }
    do{
        z=c;
        mn=min(mn,brute());
    }while(next_permutation(s.begin(),s.end()));
    return mn;
}

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

shoes.cpp: In function 'long long int count_swaps(std::vector<int>)':
shoes.cpp:51:11: error: no match for 'operator=' (operand types are 'std::vector<long long int>' and 'std::vector<int>')
   51 |         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)
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~