답안 #1010393

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1010393 2024-06-29T03:33:41 Z AnhPham Job Scheduling (IOI19_job) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
 
#ifdef OP_DEBUG
    #include <algo/debug.h>
#else
    #define debug(...) 26
#endif
 
using namespace std;
 
#define int 	long long
#define sz(v)   (int)(v).size()
#define all(v)  (v).begin(), (v).end()
#define TcT     template <class T
 
const   int     MOD = (int)1e9 + 7, INF = (int)4e18 + 18;
 
TcT>            bool minimize(T &lhs, const T &rhs) { return rhs < lhs ? lhs = rhs, 1 : 0; }
TcT>            bool maximize(T &lhs, const T &rhs) { return rhs > lhs ? lhs = rhs, 1 : 0; }
 
/* [Pham Hung Anh - 12I - Tran Hung Dao High School for Gifted Student] */
 
struct Info {
    int id;
    int w, t;
    bool operator < (const Info &other) const {
        return w * other.t < other.w * t;
    }
};
 
long long scheduling_cost(vector <int> p, vector <int> u, vector <int> d) {
    int n = sz(p);
    vector <vector <int>> adj(n);
    for (int i = 1; i < n; ++i)
        adj[p[i]].emplace_back(i);
    
    long long tot_time = 0, ans = 0;
    priority_queue <Info> pq; pq.push({ 0, u[0], d[0] });
    while (sz(pq)) {
        Info job = pq.top(); pq.pop();  
        tot_time += d[job.id];
        ans += tot_time * u[job.id];
        for (int v : adj[job.id])
            pq.push({ v, u[v], d[v] });
    }
 
    return ans;
}
 
// void solve() {
//     int n; cin >> n;
 
//     vector <int> P(n), W(n), T(n);
//     for (int &p : P)
//         cin >> p;
    
//     for (int &w : W)
//         cin >> w;
    
//     for (int &t : T)
//         cin >> t;
    
//     vector <vector <int>> adj(n);
//     for (int i = 1; i < n; ++i)
//         adj[P[i]].emplace_back(i);
    
//     int tot_time = 0, ans = 0;
//     priority_queue <Info> pq; pq.push({ 0, W[0], T[0] });
//     while (sz(pq)) {
//         Info job = pq.top(); pq.pop();  
//         tot_time += T[job.id];
//         ans += tot_time * W[job.id];
//         for (int v : adj[job.id])
//             pq.push({ v, W[v], T[v] });
//     }
 
//     cout << ans << '\n';
// }

Compilation message

/usr/bin/ld: /tmp/cc3NeELg.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