Submission #120920

# Submission time Handle Problem Language Result Execution time Memory
120920 2019-06-25T18:11:03 Z Runtime_error_ Crocodile's Underground City (IOI11_crocodile) C++14
0 / 100
4 ms 2816 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];
set<pair<int,int> > s;
 
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,s.insert(make_pair(0, P[i] ));
 
    while(!s.empty()){
        pair<int,int> p = *s.begin();
        s.erase(s.begin());
        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( u == 0)
            return dis;
        if(vis[u])
            continue;
        vis[u] = 1;

        for(auto v:adj[u])
          	if(!vis[v.first])
          	  s.insert(make_pair(dis+v.second,v.first));
    }
    return -1;
}
# 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 Incorrect 4 ms 2816 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 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 Incorrect 4 ms 2816 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 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 Incorrect 4 ms 2816 KB Output isn't correct
5 Halted 0 ms 0 KB -