제출 #1038974

#제출 시각아이디문제언어결과실행 시간메모리
1038974Zicrus추월 (IOI23_overtaking)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h>
#include "overtaking.h"
using namespace std;

typedef long long ll;

vector<ll> tCur, tNxt;
vector<int> s;
int x, m;

void init(int l, int n, vector<ll> t, vector<int> w, int x1, int m1, vector<int> s1) {
    s = s1;
    m = m1;
    x = x1;
    tCur = vector<vector<ll>>(m-1);
    tNxt = vector<vector<ll>>(m-1);
    vector<pair<ll, ll>> busses(n);
    for (int i = 0; i < n; i++) {
        busses[i] = {t[i], w[i]};
    }
    sort(busses.begin(), busses.end());

    for (int i = 0; i < n; i++) {
        ll curTime = busses[i].first;
        ll idealNxt = curTime + busses[i].second * (s[1] - s[0]);
        auto iter = lower_bound(tCur.begin(), tCur.end(), curTime);
        ll id = iter - tCur.begin();
        ll mxNxt = id > 0 ? tNxt[id-1] : 0;
        ll nxt = max(idealNxt, mxNxt);
        if (nxt > mxNxt) {
            if (id < tCur.size() && curTime == tCur[id]) {
                tNxt[id] = nxt;
            }
            else {
                auto iter2 = upper_bound(tNxt.begin(), tNxt.end(), nxt);
                tCur.erase(iter, tCur.begin() + (iter2 - tNxt.begin()));
                tNxt.erase(tNxt.begin() + id, iter2);

                tCur.insert(iter, curTime);
                tNxt.insert(tNxt.begin() + id, nxt);
            }
        }
    }
}

ll arrival_time(ll y) {
    ll idealNxt = y + x * (s[1] - s[0]);
    ll id = lower_bound(tCur.begin(), tCur.end(), y) - tCur.begin();
    ll mxNxt = id > 0 ? tNxt[id-1] : 0;
    return max(idealNxt, mxNxt);
}

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

overtaking.cpp: In function 'void init(int, int, std::vector<long long int>, std::vector<int>, int, int, std::vector<int>)':
overtaking.cpp:15:34: error: no match for 'operator=' (operand types are 'std::vector<long long int>' and 'std::vector<std::vector<long long int> >')
   15 |     tCur = vector<vector<ll>>(m-1);
      |                                  ^
In file included from /usr/include/c++/10/vector:72,
                 from /usr/include/c++/10/functional:62,
                 from /usr/include/c++/10/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/10/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from overtaking.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<std::vector<long long 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/functional:62,
                 from /usr/include/c++/10/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/10/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from overtaking.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<std::vector<long long 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<std::vector<long long int> >' to 'std::initializer_list<long long int>'
  730 |       operator=(initializer_list<value_type> __l)
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
overtaking.cpp:16:34: error: no match for 'operator=' (operand types are 'std::vector<long long int>' and 'std::vector<std::vector<long long int> >')
   16 |     tNxt = vector<vector<ll>>(m-1);
      |                                  ^
In file included from /usr/include/c++/10/vector:72,
                 from /usr/include/c++/10/functional:62,
                 from /usr/include/c++/10/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/10/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from overtaking.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<std::vector<long long 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/functional:62,
                 from /usr/include/c++/10/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/10/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from overtaking.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<std::vector<long long 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<std::vector<long long int> >' to 'std::initializer_list<long long int>'
  730 |       operator=(initializer_list<value_type> __l)
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
overtaking.cpp:31:20: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |             if (id < tCur.size() && curTime == tCur[id]) {
      |                 ~~~^~~~~~~~~~~~~