Submission #821090

# Submission time Handle Problem Language Result Execution time Memory
821090 2023-08-11T07:25:32 Z Alihan_8 Factories (JOI14_factories) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>

using namespace std;

#define all(x) x.begin(), x.end()
#define pb push_back
#define ln '\n'
#define int long long

template <class _T>
bool chmin(_T &x, const _T &y){
    bool flag = false;
    if ( x > y ){
        x = y; flag |= true;
    }
    return flag;
}

template <class _T>
bool chmax(_T &x, const _T &y){
    bool flag = false;
    if ( x < y ){
        x = y; flag |= true;
    }
    return flag;
}

const int inf = 1e16 + 1;

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int n, q; cin >> n >> q;
    vector <pair<int,int>> g[n];
    for ( int i = 0; i + 1 < n; i++ ){
        int x, y, w; cin >> x >> y >> w;
        g[x].pb({y, w});
        g[y].pb({x, w});
    }
    while ( q-- ){
        int X, Y; cin >> X >> Y;
        priority_queue <pair<int,int>> q;
        vector <int> dis(n, inf);
        for ( int i = 0; i < X; i++ ){
            int u; cin >> u;
            dis[u] = 0;
            q.push({0, u});
        }
        while ( !q.empty() ){
            auto [val, u] = q.top();
            q.pop(); val *= -1;
            if ( dis[u] != val ){
                continue;
            }
            for ( auto [v, w]: g[u] ){
                if ( chmin(dis[v], dis[u] + w) ){
                    q.push({-dis[v], v});
                }

            }
        }
        int ans = inf;
        for ( int i = 0; i < Y; i++ ){
            int u; cin >> u;
            chmin(ans, dis[u]);
        }
        cout << ans << ln;
    }


    cout << '\n';
}

Compilation message

/usr/bin/ld: /tmp/ccYlwLqH.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccG2c5gF.o:factories.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/ccYlwLqH.o: in function `main':
grader.cpp:(.text.startup+0x37d): undefined reference to `Init(int, int*, int*, int*)'
/usr/bin/ld: grader.cpp:(.text.startup+0x412): undefined reference to `Query(int, int*, int, int*)'
collect2: error: ld returned 1 exit status