Submission #113641

# Submission time Handle Problem Language Result Execution time Memory
113641 2019-05-27T10:01:27 Z Mercenary Crocodile's Underground City (IOI11_crocodile) C++14
100 / 100
771 ms 89416 KB
#include "crocodile.h"
#include<bits/stdc++.h>

using namespace std;
const int maxn = 1e5 + 5;
const long long inf = (long long)1e18 + 5;
typedef long long ll;
typedef pair<ll,int> ii;
#define pb push_back
#define mp make_pair

int travel_plan(int N, int M, int R[][2], int L[], int K, int P[])
{
    priority_queue<ii,vector<ii>,greater<ii>> pq;
    vector<ll> d(N , inf) , d1(N , inf);
    vector<vector<ii>> adj(N);
    for(int i = 0 ; i < M ; ++i){
        adj[R[i][0]].pb(mp(R[i][1] , L[i]));
        adj[R[i][1]].pb(mp(R[i][0] , L[i]));
    }
    for(int i = 0 ; i < K ; ++i){
        d[P[i]] = d1[P[i]] = 0;
        pq.push(mp(0 , P[i]));
    }
    while(!pq.empty()){
        auto u = pq.top();pq.pop();
//        printf("%d %d\n",u.first,u.second);
        if(d1[u.second] != u.first)continue;
        for(ii c : adj[u.second]){
            if(d[c.first] > u.first + c.second){
                if(d1[c.first] != d[c.first]){
                    d1[c.first] = d[c.first];
                    pq.push(mp(d1[c.first] , c.first));
                }
                d[c.first] = u.first + c.second;
            }else if(d1[c.first] > u.first + c.second){
                d1[c.first] = u.first + c.second;
                pq.push(mp(d1[c.first] , c.first));
            }
        }
    }
    return d1[0];
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 3 ms 384 KB Output is correct
4 Correct 3 ms 512 KB Output is correct
5 Correct 3 ms 512 KB Output is correct
6 Correct 3 ms 484 KB Output is correct
7 Correct 6 ms 512 KB Output is correct
8 Correct 2 ms 512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 3 ms 384 KB Output is correct
4 Correct 3 ms 512 KB Output is correct
5 Correct 3 ms 512 KB Output is correct
6 Correct 3 ms 484 KB Output is correct
7 Correct 6 ms 512 KB Output is correct
8 Correct 2 ms 512 KB Output is correct
9 Correct 4 ms 896 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 3 ms 512 KB Output is correct
12 Correct 11 ms 1024 KB Output is correct
13 Correct 5 ms 1136 KB Output is correct
14 Correct 3 ms 384 KB Output is correct
15 Correct 3 ms 512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 3 ms 384 KB Output is correct
4 Correct 3 ms 512 KB Output is correct
5 Correct 3 ms 512 KB Output is correct
6 Correct 3 ms 484 KB Output is correct
7 Correct 6 ms 512 KB Output is correct
8 Correct 2 ms 512 KB Output is correct
9 Correct 4 ms 896 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 3 ms 512 KB Output is correct
12 Correct 11 ms 1024 KB Output is correct
13 Correct 5 ms 1136 KB Output is correct
14 Correct 3 ms 384 KB Output is correct
15 Correct 3 ms 512 KB Output is correct
16 Correct 628 ms 81376 KB Output is correct
17 Correct 82 ms 17784 KB Output is correct
18 Correct 111 ms 20216 KB Output is correct
19 Correct 771 ms 89416 KB Output is correct
20 Correct 319 ms 65528 KB Output is correct
21 Correct 40 ms 8184 KB Output is correct
22 Correct 329 ms 62632 KB Output is correct