Submission #245796

# Submission time Handle Problem Language Result Execution time Memory
245796 2020-07-07T12:27:47 Z quocnguyen1012 Job Scheduling (IOI19_job) C++14
Compilation error
0 ms 0 KB
#include<bits/stdc++.h>
#define ll long long
 
using namespace std;
ll N,t = 0,ans = 0;
ll DSU[300009],fin[300009];
vector<ll> tim,cost;
ll Find(ll a)
{
    if(a == DSU[a]) return a;
    DSU[a] = Find(DSU[a]);
    return DSU[a];
}
struct cmp{
    bool operator()(ll a, ll b)const {
        if(cost[a]*tim[b] != cost[b]*tim[a]) return cost[a]*tim[b] > cost[b]*tim[a];
        return a < b;
    }
};
set<ll,cmp> st;
ll scheduling_cost(vector<int> P,vector<int> U,vector<int> D)
{
    N = P.size();
    tim.resize(N);
    cost.resize(N);
    ll i;
  	tim = D;
  	cost = U;
    for(i = 0;i < N;i++)
    {
         DSU[i] = i;
         fin[i] = 0;
         st.insert(i);
    }
    for(i = 0;i < N;i++)
    {
         ll now = *st.begin();
         st.erase(now);
         if(P[now] == -1 || fin[Find(P[now])] == 1)
         {
             t += tim[now];
             ans += cost[now]*t;
             fin[now] = 1;
             continue;
         }
         ll top = Find(P[now]);
         st.erase(top);
         ans -= cost[top]*tim[now];
         cost[top] += cost[now];
         tim[top] += tim[now];
         st.insert(top);
         DSU[now] = top;
    }
    return ans;
}

Compilation message

job.cpp: In function 'long long int scheduling_cost(std::vector<int>, std::vector<int>, std::vector<int>)':
job.cpp:27:10: error: no match for 'operator=' (operand types are 'std::vector<long long int>' and 'std::vector<int>')
    tim = D;
          ^
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 job.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 'std::vector<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 job.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 'std::vector<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 'std::vector<int>' to 'std::initializer_list<long long int>'
job.cpp:28:11: error: no match for 'operator=' (operand types are 'std::vector<long long int>' and 'std::vector<int>')
    cost = U;
           ^
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 job.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 'std::vector<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 job.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 'std::vector<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 'std::vector<int>' to 'std::initializer_list<long long int>'