답안 #155072

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
155072 2019-09-26T07:17:46 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{
  ll 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;
      t[P[nek.id]].d+=t[nek.id].d;
      ans+=t[P[nek.id]].d * t[nek.id].u;
      t[P[nek.id]].u+=t[nek.id].u;
      for(auto&& j : t[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:8:17: error: invalid declarator before 'chs'
   ll vector<ll> chs;ll u, d, id;
                 ^~~
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:20: error: 'p' was not declared in this scope
   loop(i, 1, n) ts[p[i]].push_back(i);
                    ^
job.cpp:26:10: error: expected ']' before '[' token
       t[P[nek.id]].d+=t[nek.id].d;
          ^
job.cpp:26:8: warning: decomposition declaration only available with -std=c++1z or -std=gnu++1z
       t[P[nek.id]].d+=t[nek.id].d;
        ^
job.cpp:26:8: error: decomposition declaration cannot be declared with type 't'
job.cpp:26:8: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto'
job.cpp:26:19: error: expected initializer before '.' token
       t[P[nek.id]].d+=t[nek.id].d;
                   ^
job.cpp:26:19: error: expected ',' or ';' before '.' token
job.cpp:27:13: error: expected primary-expression before '[' token
       ans+=t[P[nek.id]].d * t[nek.id].u;
             ^
job.cpp:27:30: error: expected primary-expression before '[' token
       ans+=t[P[nek.id]].d * t[nek.id].u;
                              ^
job.cpp:28:10: error: expected ']' before '[' token
       t[P[nek.id]].u+=t[nek.id].u;
          ^
job.cpp:28:8: warning: decomposition declaration only available with -std=c++1z or -std=gnu++1z
       t[P[nek.id]].u+=t[nek.id].u;
        ^
job.cpp:28:8: error: decomposition declaration cannot be declared with type 't'
job.cpp:28:8: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto'
job.cpp:28:19: error: expected initializer before '.' token
       t[P[nek.id]].u+=t[nek.id].u;
                   ^
job.cpp:29:23: error: expected primary-expression before '[' token
       for(auto&& j : t[nek.id].chs) P[j]=P[nek.id];
                       ^
job.cpp:30:34: error: expected ']' before ')' token
       if(nek.id!=n&&act[P[nek.id]) q.push(ts[P[nek.id]]);
                                  ^