Submission #711857

# Submission time Handle Problem Language Result Execution time Memory
711857 2023-03-17T15:21:47 Z onjo0127 Job Scheduling (IOI19_job) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;
using pli = pair<long long, int>;
const long long INF = 1LL * 1e18;
int P[200009], pa[200009];
long long A[200009], B[200009], T[200009];
bool chk[200009];
struct info { int v; };
bool operator <(info p, info q) {
    return (pli){A[q.v] * T[p.v], p.v} < (pli){A[p.v] * T[q.v], q.v};
}
int root(int x) {
    if(pa[x] == x) return x;
    return pa[x] = root(pa[x]);
}
int main() {
    int N; scanf("%d",&N);
    for(int i=1; i<=N; i++) {
        int d, t; scanf("%d%d%d", &P[i], &d, &t);
        A[i] = d, B[i] = d*t, T[i] = t;
        pa[i] = i;
    }
    set<info> st;
    for(int i=2; i<=N; i++) st.insert({i});
    while(st.size()) {
        int x = (*st.begin()).v; st.erase(st.begin());
        pa[x] = P[x] = root(P[x]);
        if(P[x] != 1) st.erase({P[x]});
        B[P[x]] += B[x] + A[x]*T[P[x]];
        A[P[x]] += A[x];
        T[P[x]] += T[x];
        if(P[x] != 1) st.insert({P[x]});
    }
    printf("%lld", B[1]);
    return 0;
}

Compilation message

job.cpp: In function 'int main()':
job.cpp:17:17: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |     int N; scanf("%d",&N);
      |            ~~~~~^~~~~~~~~
job.cpp:19:24: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   19 |         int d, t; scanf("%d%d%d", &P[i], &d, &t);
      |                   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
/usr/bin/ld: /tmp/cc4OUGuV.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccjj3iGZ.o:job.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/cc4OUGuV.o: in function `main':
grader.cpp:(.text.startup+0x2b1): 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