Submission #120934

# Submission time Handle Problem Language Result Execution time Memory
120934 2019-06-25T18:34:35 Z Runtime_error_ Crocodile's Underground City (IOI11_crocodile) C++14
100 / 100
694 ms 56396 KB
#include "crocodile.h"
#include <bits/stdc++.h>
#include <stdio.h>
#include <stdlib.h>
using namespace std;

const int inf=1e5+9,MX=1e9+9;
vector< pair<int,int> > adj[inf];
bool ex[inf],vis[inf];
//we have to use multi set because we might visit the same node twice with the same distance
//multiset will time out so we use priority queue
priority_queue<pair<int,int> > pq;

int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]){

    for(int i=0;i<M;i++)
        adj[ R[i][0] ].push_back( make_pair( R[i][1] , L[i] ) ),
        adj[ R[i][1] ].push_back(make_pair( R[i][0] , L[i] ));

    for(int i=0;i<K;i++)
        ex[ P[i] ] = 1,pq.push(make_pair(0, P[i] ));

    while(!pq.empty()){
        pair<int,int> p = pq.top();
        pq.pop();
        int u = p.second , dis = -p.first;

        if( ex[u] == 0 ){
            // we want the second minimum distance so when we reach a node that are not an exit for the first time we abort
            //and make that we visited it once
            ex[u] = 1;
            continue;
        }

        if(vis[u])
            continue;
        vis[u] = 1;
        if( u == 0)
            return dis;
        for(auto v:adj[u])
            pq.push(make_pair( -(dis+v.second),v.first));
    }
}

Compilation message

crocodile.cpp: In function 'int travel_plan(int, int, int (*)[2], int*, int, int*)':
crocodile.cpp:43:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
# Verdict Execution time Memory Grader output
1 Correct 4 ms 2688 KB Output is correct
2 Correct 4 ms 2688 KB Output is correct
3 Correct 4 ms 2688 KB Output is correct
4 Correct 5 ms 2724 KB Output is correct
5 Correct 4 ms 2816 KB Output is correct
6 Correct 4 ms 2688 KB Output is correct
7 Correct 5 ms 2816 KB Output is correct
8 Correct 4 ms 2688 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 2688 KB Output is correct
2 Correct 4 ms 2688 KB Output is correct
3 Correct 4 ms 2688 KB Output is correct
4 Correct 5 ms 2724 KB Output is correct
5 Correct 4 ms 2816 KB Output is correct
6 Correct 4 ms 2688 KB Output is correct
7 Correct 5 ms 2816 KB Output is correct
8 Correct 4 ms 2688 KB Output is correct
9 Correct 6 ms 3072 KB Output is correct
10 Correct 3 ms 2688 KB Output is correct
11 Correct 5 ms 2816 KB Output is correct
12 Correct 9 ms 3456 KB Output is correct
13 Correct 7 ms 3456 KB Output is correct
14 Correct 4 ms 2688 KB Output is correct
15 Correct 4 ms 2816 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 2688 KB Output is correct
2 Correct 4 ms 2688 KB Output is correct
3 Correct 4 ms 2688 KB Output is correct
4 Correct 5 ms 2724 KB Output is correct
5 Correct 4 ms 2816 KB Output is correct
6 Correct 4 ms 2688 KB Output is correct
7 Correct 5 ms 2816 KB Output is correct
8 Correct 4 ms 2688 KB Output is correct
9 Correct 6 ms 3072 KB Output is correct
10 Correct 3 ms 2688 KB Output is correct
11 Correct 5 ms 2816 KB Output is correct
12 Correct 9 ms 3456 KB Output is correct
13 Correct 7 ms 3456 KB Output is correct
14 Correct 4 ms 2688 KB Output is correct
15 Correct 4 ms 2816 KB Output is correct
16 Correct 597 ms 56396 KB Output is correct
17 Correct 95 ms 9848 KB Output is correct
18 Correct 104 ms 11268 KB Output is correct
19 Correct 694 ms 50512 KB Output is correct
20 Correct 354 ms 53124 KB Output is correct
21 Correct 51 ms 6136 KB Output is correct
22 Correct 589 ms 32248 KB Output is correct