Submission #984606

# Submission time Handle Problem Language Result Execution time Memory
984606 2024-05-16T20:59:48 Z ag_1204 Cyberland (APIO23_cyberland) C++17
Compilation error
0 ms 0 KB
#include<bits/stdc++.h>
using namespace std;

vector<pair<int, int> > graph[100001];
vector<vector<int> > edges;

void add_edge(int u, int v, int w)
{
    graph[u].push_back({ v, w });
    graph[v].push_back({ u, w });
    edges.push_back({ u, v, w });
}

vector<int> dijsktras(int src, int N)
{
    vector<int> dis(N, INT_MAX);
    vector<bool> vis(N, false);
    priority_queue<pair<int, int>,
                   vector<pair<int, int> >,
                   greater<pair<int, int> > >
        pq;
    pq.push({ 0, src });
    dis[src] = 0;
    while (!pq.empty()) {
        auto cur = pq.top();
        pq.pop();
        int node = cur.second;
        int weight = cur.first;
        if (vis[node])
            continue;
        vis[node] = true;
        for (auto child : graph[node]) {
            if (dis[child.first]
                > child.second + weight) {
                dis[child.first] = weight
                                   + child.second;
                pq.push({ dis[child.first],
                          child.first });
            }
        }
    }
    return dis;
}
int shortestDistance(int N, int M,
                     int A, int B)
{
    vector<int> disA = dijsktras(A, N);
    int ans = disA[B];
    return ans;
}

double solve(int N, int M, int K, int H, std::vector<int> x, std::vector<int> y, std::vector<int> c, std::vector<int> arr) {

    return (double) shortestDistance(N,M,0,H);
}

int main(){
    ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int t; cin>>t;
    while(t--) {
        int N,M,K; cin>>N>>M>>K;
        int H; cin>>H;
        vector<int> arr(N),x(M),y(M),c(M);
        for (int i=0;i<N;i++) {
            cin>>arr[i];
        }
        for (int i=0;i<M;i++) {
            cin>>x[i];
        }
        for (int i=0;i<M;i++) {
            cin>>y[i];
        }
        for (int i=0;i<M;i++) {
            cin>>c[i];
            add_edge(x[i],y[i],c[i]);
        }
        double d=solve(N,M,K,H,x,y,c,arr);
        cout << d << endl;
        for (int i=0;i<100001;i++) {
            graph[i].clear();
        }
    }
}

Compilation message

/usr/bin/ld: /tmp/ccOyfIMc.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccQC9n5b.o:cyberland.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status