답안 #821285

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
821285 2023-08-11T08:41:10 Z vjudge1 고대 책들 (IOI17_books) C++14
컴파일 오류
0 ms 0 KB
#include<bits/stdc++.h>
#include "books.h"
#define fi first
#define se second
#define ll long long
using namespace std ;
ll ans = 1e18 ;
ll sz ;
vector<ll> now ;
bool check()
{
    vector<ll> gr = now ;
    sort(gr.begin(), gr.end()) ;
    return (now == gr) ;
}
void rec(ll ind, ll cnt, ll sum, ll with)
{
//    cout<<ind<<' '<<cnt << ' ' << with << '\n' ;
    if(with == -1 && check())
    {
        ans = min(ans, sum + ind) ;
        return ;
    }
    if(cnt == 16)
        return ;
    if(with != -1)
    {
        swap(now[ind], with) ;
        rec(ind, cnt + 1, sum, with) ;
        swap(now[ind], with) ;
    }
    else
    {
        if(now[ind] != -1)
        {
            swap(now[ind], with) ;
            rec(ind, cnt + 1, sum, with) ;
            swap(now[ind], with) ;
        }
    }
    if(ind < sz - 1)
        rec(ind + 1, cnt + 1, sum + 1, with) ;
    if(ind)
        rec(ind - 1, cnt + 1, sum + 1, with) ;
}
ll minimum_walk(vector<int> p, int s)
{
    sz = p.size() ;
    if(sz <= 4)
    {
        now = p ;
        rec(s, 0, 0, -1) ;
    }
    return ans ;
}
//signed main()
//{
//    ll n, s ;
//    cin >> n >> s ;
//    vector<ll> p(n) ;
//    for(ll i = 0 ; i < n ; i++)
//        cin >> p[i] ;
//    cout << minimum_walk(p, s) ;
//    return 0 ;
//}

Compilation message

books.cpp: In function 'long long int minimum_walk(std::vector<int>, int)':
books.cpp:51:15: error: no match for 'operator=' (operand types are 'std::vector<long long int>' and 'std::vector<int>')
   51 |         now = p ;
      |               ^
In file included from /usr/include/c++/10/vector:72,
                 from /usr/include/c++/10/queue:61,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:86,
                 from books.cpp:1:
/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 /usr/include/c++/10/queue:61,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:86,
                 from books.cpp:1:
/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)
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~