Submission #1286660

#TimeUsernameProblemLanguageResultExecution timeMemory
1286660MMihalevOvertaking (IOI23_overtaking)C++20
Compilation error
0 ms0 KiB
#include<iostream>
#include<algorithm>
#include<vector>
#include "overtaking.h"
using namespace std;
struct line
{
    long long m,c;
    long long calc(long long x){return m*x+c;}
    long double intersect(line l){return (long double)(c-l.c)/(l.m-m);}
};
vector<line>lines;
vector<long long>s;
long long l,n,m,x;
void init(int L, int N, std::vector<long long> T, std::vector<int> W, int X, int M, std::vector<int> S)
{
    l=L;
    n=N;
    x=X;
    m=M;
    s=S;
    vector<pair<int,int>>order;
    for(int i=0;i<n;i++)
    {
        order.push_back({W[i],i});
    }
    sort(order.begin(),order.end());
    for(int i=0;i<n;i++)
    {
        int id=order[i].second;
        line l;
        l.m=W[id];
        l.c=T[id];
        lines.push_back(l);
    }
}

long long arrival_time(long long Y)
{
    line cur;
    cur.m=x;
    cur.c=Y;
    if(cur.m>=lines[0].m)
    {
        return cur.calc(l);
    }

    auto point=cur.intersect(lines[0]);

    for(int j=0;j<m;j++)
    {
        if(s[j]>=point)
        {
            return cur.calc(l);
        }
        if(s[j]>point)
        {
            long long dist=lines[0].calc(s[j]);
            return (l-dist)*x;
        }
    }
}

Compilation message (stderr)

overtaking.cpp: In function 'void init(int, int, std::vector<long long int>, std::vector<int>, int, int, std::vector<int>)':
overtaking.cpp:21:7: error: no match for 'operator=' (operand types are 'std::vector<long long int>' and 'std::vector<int>')
   21 |     s=S;
      |       ^
In file included from /usr/include/c++/13/vector:72,
                 from overtaking.cpp:3:
/usr/include/c++/13/bits/vector.tcc:210:5: note: candidate: 'constexpr 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>]'
  210 |     vector<_Tp, _Alloc>::
      |     ^~~~~~~~~~~~~~~~~~~
/usr/include/c++/13/bits/vector.tcc:211:42: note:   no known conversion for argument 1 from 'std::vector<int>' to 'const std::vector<long long int>&'
  211 |     operator=(const vector<_Tp, _Alloc>& __x)
      |               ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
In file included from /usr/include/c++/13/vector:66:
/usr/include/c++/13/bits/stl_vector.h:766:7: note: candidate: 'constexpr std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::vector<_Tp, _Alloc>&&) [with _Tp = long long int; _Alloc = std::allocator<long long int>]'
  766 |       operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
      |       ^~~~~~~~
/usr/include/c++/13/bits/stl_vector.h:766:26: note:   no known conversion for argument 1 from 'std::vector<int>' to 'std::vector<long long int>&&'
  766 |       operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
      |                 ~~~~~~~~~^~~
/usr/include/c++/13/bits/stl_vector.h:788:7: note: candidate: 'constexpr std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::initializer_list<_Tp>) [with _Tp = long long int; _Alloc = std::allocator<long long int>]'
  788 |       operator=(initializer_list<value_type> __l)
      |       ^~~~~~~~
/usr/include/c++/13/bits/stl_vector.h:788:46: note:   no known conversion for argument 1 from 'std::vector<int>' to 'std::initializer_list<long long int>'
  788 |       operator=(initializer_list<value_type> __l)
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
overtaking.cpp: In function 'long long int arrival_time(long long int)':
overtaking.cpp:62:1: warning: control reaches end of non-void function [-Wreturn-type]
   62 | }
      | ^