Submission #635531

# Submission time Handle Problem Language Result Execution time Memory
635531 2022-08-26T11:29:21 Z tabr Job Scheduling (IOI19_job) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;
#ifdef tabr
#include "library/debug.cpp"
#else
#define debug(...)
#endif

long long scheduling_cost(vector<int> p, vector<int> u, vector<int> d) {
    int n = (int) p.size();
    vector<vector<int>> g(n);
    for (int i = 1; i < n; i++) {
        g[p[i]].emplace_back(i);
    }
    auto Merge = [&](vector<int> a, vector<int> b) {
        int sa = (int) a.size();
        int sb = (int) b.size();
        vector<int> c;
        for (int i = 0, j = 0; i < sa; i++) {
            while (j < sb && d[b[j]] * u[a[i]] < d[a[i]] * u[b[j]]) {
                c.emplace_back(b[j]);
                j++;
            }
            c.emplace_back(a[i]) :
        }
        return c;
        /*
        vector<long long> da(sa + 1), db(sb + 1);
        for (int i = 0; i < sa; i++) {
            da[i + 1] = da[i] + d[a[i]];
        }
        for (int i = 0; i < sb; i++) {
            db[i + 1] = db[i] + d[b[i]];
        }
        const long long inf = (long long) 1e18;
        vector<vector<long long>> dp(sa + 1, vector<long long>(sb + 1, inf));
        dp[0][0] = 0;
        for (int i = 0; i <= sa; i++) {
            for (int j = 0; j <= sb; j++) {
                if (i < sa) {
                    dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + (da[i + 1] + db[j]) * u[a[i]]);
                }
                if (j < sb) {
                    dp[i][j + 1] = min(dp[i][j + 1], dp[i][j] + (da[i] + db[j + 1]) * u[b[j]]);
                }
            }
        }
        vector<int> c;
        int x = sa, y = sb;
        while (x > 0 || y > 0) {
            if (x > 0 && dp[x][y] == dp[x - 1][y] + (da[x] + db[y]) * u[a[x - 1]]) {
                c.emplace_back(a[x - 1]);
                x--;
            } else if (y > 0 && dp[x][y] == dp[x][y - 1] + (da[x] + db[y]) * u[b[y - 1]]) {
                c.emplace_back(b[y - 1]);
                y--;
            } else {
                assert(false);
            }
        }
        reverse(c.begin(), c.end());
        return c;
        */
    };
    vector<vector<int>> a(n);
    function<void(int)> Dfs = [&](int v) {
        for (int to : g[v]) {
            Dfs(to);
            a[v] = Merge(a[v], a[to]);
        }
        a[v].insert(a[v].begin(), v);
    };
    Dfs(0);
    long long res = 0;
    long long t = 0;
    for (int i : a[0]) {
        t += d[i];
        res += t * u[i];
    }
    return res;
}
#ifdef tabr
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    debug(scheduling_cost({-1, 0, 0}, {5, 2, 5}, {3, 4, 1}));
    return 0;
}
#endif

Compilation message

job.cpp: In lambda function:
job.cpp:24:33: error: expected ';' before ':' token
   24 |             c.emplace_back(a[i]) :
      |                                 ^~
      |                                 ;