제출 #146773

#제출 시각아이디문제언어결과실행 시간메모리
146773youssan_williamArranging Shoes (IOI19_shoes)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h>
#include "shoes.h"
using namespace std;
typedef long long ll;
bool v[100005]; 
ll count_swaps( vector<ll>s )
{
    ll n = s.size();
    ll tmp;
    ll ans=0;
    for(int i = 1 ; i <=2*n ; i++)
    {
        if(!v[abs(s[i])])
        {
            v[abs(s[i])]=1;
            for(int j =i+1 ; j <= 2 * n ;j++)
            {
                if(abs(s[i])==abs(s[j]))
                {
                    for(int k=j-1 ; k>i ;k--)
                    {
                        //swap(arr[k],arr[k+1]);
                        s=s[k];
                        s[k]=s[k+1];
                        s[k+1]=tmp;
                        ans++;
                    }
                    break;
                }
            }
        }
    }
    for(int i = 1 ;  i <=2*n ;i++ )
    {
        if(i%2==1&&s[i]>s[i+1])
            ans++;
    }
    return ans;
}

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

shoes.cpp: In function 'll count_swaps(std::vector<long long int>)':
shoes.cpp:23:30: error: no match for 'operator=' (operand types are 'std::vector<long long int>' and '__gnu_cxx::__alloc_traits<std::allocator<long long int> >::value_type {aka long long int}')
                         s=s[k];
                              ^
In file included from /usr/include/c++/7/vector:69:0,
                 from /usr/include/c++/7/queue:61,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:86,
                 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 = long long int; _Alloc = std::allocator<long long int>]
     vector<_Tp, _Alloc>::
     ^~~~~~~~~~~~~~~~~~~
/usr/include/c++/7/bits/vector.tcc:179:5: note:   no known conversion for argument 1 from '__gnu_cxx::__alloc_traits<std::allocator<long long int> >::value_type {aka long long int}' to 'const std::vector<long long int>&'
In file included from /usr/include/c++/7/vector:64:0,
                 from /usr/include/c++/7/queue:61,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:86,
                 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 = long long int; _Alloc = std::allocator<long long 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 '__gnu_cxx::__alloc_traits<std::allocator<long long int> >::value_type {aka long long int}' to 'std::vector<long long 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 = long long int; _Alloc = std::allocator<long long 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 '__gnu_cxx::__alloc_traits<std::allocator<long long int> >::value_type {aka long long int}' to 'std::initializer_list<long long int>'