Submission #398427

# Submission time Handle Problem Language Result Execution time Memory
398427 2021-05-04T09:09:41 Z AugustinasJucas Crocodile's Underground City (IOI11_crocodile) C++14
Compilation error
0 ms 0 KB
//#include "crocodile.h"
#include <bits/stdc++.h>
using namespace std;
const int dydis = 1e5 + 10;
const long long inf = 1e18;
vector<pair<int, int> > gr[dydis];
int n, m, k;
pair<long long, long long> dist[dydis];
int kek[dydis];
bool don[dydis];
int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]){
    n = N; m = M; k = K;
    for(int i = 0; i < n; i++) dist[i] = {inf, inf};
    for(int i = 0; i < M; i++) {
        gr[R[i][0]].push_back({R[i][1], L[i]});
        gr[R[i][1]].push_back({R[i][0], L[i]});
    }
    priority_queue<pair<int, int> > q;
    for(int i = 0; i < k; i++){
        q.push({0, P[i]});
    }
    while(q.size()){
        int v = q.top().second;
        long long dst = -q.top().first;
        q.pop();
        if(don[v]) continue;
        if(dst != 0 && (dst == inf || dst != dist[v].second)) continue;
        don[v] = 1;
        for(auto x : gr[v]){
            long long gal = x.second + dst;
            if(gal < dist[x.first].first){
                dist[x.first].second = dist[x.first].first;
                dist[x.first].first = gal;
                q.push({-dist[x.first].second, x.first});
            }else if(gal < dist[x.first].second){
                dist[x.first].second = gal;
                q.push({-dist[x.first].second, x.first});
            }
        }
    }
    return dist[0].second;
}

int main(){
    int n, m, k; cin >> n >> m >> k;
    int R[m][2];
    int L[m];
    int P[k];
    for(int i = 0; i < m; i++){
        int a, b, c; cin >> a >> b >> c;
        R[i][0] = a;
        R[i][1] = b;
        L[i] = c;
    }
    for(int i = 0; i < k; i++) cin >> P[i];

    int ans = travel_plan(n, m, R, L, k, P);

    cout << ans;

}
/*
5 4 3
0 1 2
0 2 3
3 2 1
2 4 4
1 3 4

5 7 2
0 2 4
0 3 3
3 2 2
2 1 10
0 1 100
0 4 7
3 4 9
1 3
*/

Compilation message

/tmp/cccvJQgI.o: In function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/ccqJb6Jc.o:crocodile.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status