Submission #93989

# Submission time Handle Problem Language Result Execution time Memory
93989 2019-01-14T09:30:03 Z someone_aa Crocodile's Underground City (IOI11_crocodile) C++17
100 / 100
668 ms 68360 KB
#include "crocodile.h"
#include <bits/stdc++.h>
#define ll long long
#define pll pair<ll, ll>
#define pb push_back
#define mp make_pair
using namespace std;
const int maxn = 100100;
ll distf[maxn], dists[maxn];
vector<pair<int,int> > g[maxn];
bool f[maxn], visited[maxn];

int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]) {
    for(int i=0;i<M;i++) {
        g[R[i][0]].pb(mp(R[i][1], L[i]));
        g[R[i][1]].pb(mp(R[i][0], L[i]));
    }

    for(int i=0;i<K;i++) {
        f[P[i]] = true;
    }

    priority_queue<pll, vector<pll>, greater<pll> > pq;

    for(int i=0;i<N;i++) {
        if(f[i]) {
            distf[i] = dists[i] = 0;
            pq.push(mp(0, i));
        }
        else {
            distf[i] = dists[i] = INT_MAX;
        }
    }

    while(!pq.empty()) {
        pll curr = pq.top();
        pq.pop();

        if(visited[curr.second]) continue;
        visited[curr.second] = true;

        if(curr.second == 0) {
            return dists[curr.second];
        }

        int node = curr.second;

        for(auto i:g[node]) {
            if(!visited[i.first]) {
                ll extended = dists[node] + i.second;

                if(extended < distf[i.first]) {
                    dists[i.first] = distf[i.first];
                    distf[i.first] = extended;
                    pq.push(mp(dists[i.first], i.first));
                }
                else if(extended < dists[i.first]) {
                    dists[i.first] = extended;
                    pq.push(mp(dists[i.first], i.first));
                }
            }
        }
    }
}

Compilation message

crocodile.cpp: In function 'int travel_plan(int, int, int (*)[2], int*, int, int*)':
crocodile.cpp:64:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
# Verdict Execution time Memory Grader output
1 Correct 3 ms 2680 KB Output is correct
2 Correct 4 ms 2552 KB Output is correct
3 Correct 4 ms 2680 KB Output is correct
4 Correct 4 ms 2808 KB Output is correct
5 Correct 4 ms 2808 KB Output is correct
6 Correct 4 ms 2812 KB Output is correct
7 Correct 4 ms 2808 KB Output is correct
8 Correct 4 ms 2808 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 2680 KB Output is correct
2 Correct 4 ms 2552 KB Output is correct
3 Correct 4 ms 2680 KB Output is correct
4 Correct 4 ms 2808 KB Output is correct
5 Correct 4 ms 2808 KB Output is correct
6 Correct 4 ms 2812 KB Output is correct
7 Correct 4 ms 2808 KB Output is correct
8 Correct 4 ms 2808 KB Output is correct
9 Correct 6 ms 2936 KB Output is correct
10 Correct 4 ms 2808 KB Output is correct
11 Correct 4 ms 2808 KB Output is correct
12 Correct 7 ms 3192 KB Output is correct
13 Correct 6 ms 3192 KB Output is correct
14 Correct 4 ms 2680 KB Output is correct
15 Correct 4 ms 2808 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 2680 KB Output is correct
2 Correct 4 ms 2552 KB Output is correct
3 Correct 4 ms 2680 KB Output is correct
4 Correct 4 ms 2808 KB Output is correct
5 Correct 4 ms 2808 KB Output is correct
6 Correct 4 ms 2812 KB Output is correct
7 Correct 4 ms 2808 KB Output is correct
8 Correct 4 ms 2808 KB Output is correct
9 Correct 6 ms 2936 KB Output is correct
10 Correct 4 ms 2808 KB Output is correct
11 Correct 4 ms 2808 KB Output is correct
12 Correct 7 ms 3192 KB Output is correct
13 Correct 6 ms 3192 KB Output is correct
14 Correct 4 ms 2680 KB Output is correct
15 Correct 4 ms 2808 KB Output is correct
16 Correct 571 ms 61000 KB Output is correct
17 Correct 92 ms 16908 KB Output is correct
18 Correct 98 ms 17352 KB Output is correct
19 Correct 668 ms 68360 KB Output is correct
20 Correct 292 ms 49816 KB Output is correct
21 Correct 47 ms 8744 KB Output is correct
22 Correct 346 ms 46968 KB Output is correct