답안 #155076

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
155076 2019-09-26T07:20:24 Z neki Job Scheduling (IOI19_job) C++14
컴파일 오류
0 ms 0 KB
#include "job.h"
#include <bits/stdc++.h>
using namespace std;
#define loop(i, a, b) for(int i=a;i<b;i++)
typedef long long ll;

struct t{
  vector<ll> chs;ll u, d, id;
  bool operator<(const t& oth) const {return u * oth.d>oth.u * d;}
};

t ts[200100];
int act[200100];
 
ll scheduling_cost(vector<ll> P, vector<ll> U, vector<ll> D) {
  ll n=P.size(), ans=0;
  P.push_back(0), U.push_back(0), D.push_back(0);P[0]=n;
  loop(i, 1, n) ts[P[i]].chs.push_back(i);
  loop(i, 0, n) ts[i].u=U[i], ts[i].d=D[i], ts[i].id=i, act[i]=1;
  priority_queue<t> q;
  loop(i, 0, n) q.push(ts[i]);
  while(q.size()){
    t nek=q.top(); q.pop();
    if(act[nek.id]&&nek.u==ts[nek.id].u&&nek.d==ts[nek.id].d){
      act[nek.id]=0;
      ts[P[nek.id]].d+=ts[nek.id].d;
      ans+=ts[P[nek.id]].d * ts[nek.id].u;
      ts[P[nek.id]].u+=ts[nek.id].u;
      for(auto&& j : ts[nek.id].chs) P[j]=P[nek.id];
      if(nek.id!=n&&act[P[nek.id]]) q.push(ts[P[nek.id]]);
    }
  }
  return ans;
}

Compilation message

/tmp/ccB0McpR.o: In function `main':
grader.cpp:(.text.startup+0x2bf): undefined reference to `scheduling_cost(std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status