제출 #847220

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

constexpr int MAX_SS = 1011;

// lines[i]: stores lines between i-th and (i+1)-th sorting stations
//           each line is represented by its 2 endpoints
set<pair<ll, ll>> lines[MAX_SS];
int M;
ll X;
vector<ll> S;

void init(
        int L,
        int nBus, vector<ll> T, vector<int> W,
        int _X,
        int _M, vector<int> _S) {
    M = _M;
    X = _X;
    S = _S;
    // sort buses in decreasing order of W (so slowest buses are processed first)
    vector<pair<ll, ll>> buses(nBus);
    for (int i = 0; i < nBus; ++i) buses[i] = make_pair(W[i], T[i]);
    std::sort(buses.begin(), buses.end());
    std::reverse(buses.begin(), buses.end());

    // init gaps between 2 sorting stations
    for (int i = 0; i < M-1; ++i) {  // only M-1 gaps
        lines[i].clear();
        lines[i].insert({0, 0});
    }

    // for each bus, add its line to all gaps
    for (const auto& [w, t] : buses) {
        ll cur_time = t;
        for (int j = 0; j < M-1; ++j) {
            auto it = std::prev(lines[j].lower_bound({cur_time, 0}));
            ll exit_time = std::max(it->second, cur_time + w*(S[j+1] - S[j]));
            lines[j].insert({cur_time, exit_time});

            cur_time = exit_time;
        }
    }
}

ll arrival_time(ll Y) {
    ll cur_time = Y;
    for (int j = 0; j < M-1; ++j) {
        auto it = std::prev(lines[j].lower_bound({cur_time, 0}));
        cur_time = std::max(it->second, cur_time + X*(S[j+1] - S[j]));
    }
    return cur_time;
}

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

overtaking.cpp: In function 'void init(int, int, std::vector<long long int>, std::vector<int>, int, int, std::vector<int>)':
overtaking.cpp:22:9: error: no match for 'operator=' (operand types are 'std::vector<long long int>' and 'std::vector<int>')
   22 |     S = _S;
      |         ^~
In file included from /usr/include/c++/10/vector:72,
                 from overtaking.h:1,
                 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<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 overtaking.h:1,
                 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<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)
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~