제출 #144780

#제출 시각아이디문제언어결과실행 시간메모리
144780gmfabat콤보 (IOI18_combo)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #include "job.h" #define ll long long using namespace std; const int N = 200005; int a[N], fa[N], dd[N],sz[N]; ll w[N]; struct node { int id; ll son, mom; node (int _id = 0, ll _son = 0, ll _mom = 0) {id = _id, son = _son; mom = _mom; } bool operator < (const node &b) const {return son*b.mom < b.son*mom; } }; priority_queue<node>Q; int find(int o) {return ~fa[o] ? fa[o] = find(fa[o]) : o;} ll scheduling_cost(std::vector<int> p, std::vector<int> u, std::vector<int> d) { int n=p.size(); memset(fa, -1, sizeof(fa)); for (int i = 1; i <= n; i++) { //初始化index , 由1-N 而不是0- N-1, 其實也可不做 , 但下面要小改, 注意index a[i]=p[i-1]+1; w[i]=u[i-1]; dd[i]=d[i-1]; } for (int i = 1; i <= n; i++) if (find(a[i])^find(i)) fa[find(a[i])] = find(i); long long ans = 0; int loc = 0; for (int i = 1; i <= n; i++) scanf("%lld", &w[i]); for (int i = 1; i <= n; i++) { scanf("%d", &dd[i]); Q.push(node(i, w[i], dd[i])); //建堆 sz[i] = dd[i]; ans += w[i]*dd[i]; } memset(fa, -1, sizeof(fa)); while (!Q.empty()) { // 每次合二個點合二為一, 消一個點和對應邊 , 消到堆為空為止 node t = Q.top(); Q.pop(); if (sz[t.id] != t.mom) continue; if (find(a[t.id]) == 0) { ans += w[t.id]*loc; fa[t.id] = 0; loc += sz[t.id]; }else { int tmp = find(a[t.id]); ans += w[t.id]*sz[tmp], fa[t.id] = tmp; w[tmp] += w[t.id], sz[tmp] += sz[t.id]; Q.push(node(tmp, w[tmp], sz[tmp])); } } return ans; }

컴파일 시 표준 에러 (stderr) 메시지

combo.cpp:2:10: fatal error: job.h: No such file or directory
    2 | #include "job.h"
      |          ^~~~~~~
compilation terminated.