답안 #155073

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
155073 2019-09-26T07:19:19 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]].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

job.cpp: In function 'll scheduling_cost(std::vector<long long int>, std::vector<long long int>, std::vector<long long int>)':
job.cpp:18:26: error: 'struct t' has no member named 'push_back'
   loop(i, 1, n) ts[P[i]].push_back(i);
                          ^~~~~~~~~
job.cpp:30:34: error: expected ']' before ')' token
       if(nek.id!=n&&act[P[nek.id]) q.push(ts[P[nek.id]]);
                                  ^