Submission #240459

# Submission time Handle Problem Language Result Execution time Memory
240459 2020-06-19T16:53:04 Z oscarsierra12 Crocodile's Underground City (IOI11_crocodile) C++14
0 / 100
6 ms 2688 KB
#include "crocodile.h"
#include <bits/stdc++.h>
using namespace std ;

const int N = 1e5+2 ;
#define  ff   first
#define  ss   second
#define pb    push_back

const int oo = 1e9+2 ;

vector <pair<int,int> > G[N] ;
int deg[N] ;
int fr[N], sc[N] ;
int visit[N] ;

int travel_plan(int N, int M, int R[][2], int L[], int K, int P[])
{
    for ( int i = 0 ; i < N ; ++i ) fr[i] = sc[i] = oo ;
    for ( int i = 0 ; i < M ; ++i ) G[R[i][0]].pb ( make_pair(R[i][1], L[i]) ), G[R[i][1]].pb ( make_pair(R[i][0], L[i])) ;
    queue <pair<int,int> > q ;
    for ( int i = 0 ; i < K ; ++i ) fr[P[i]] = sc[P[i]] = 0, q.push ( make_pair ( 0, P[i] ) ) ;
    while ( q.size() ) {
        pair <int,int> u = q.front() ;
        q.pop() ;
        if ( visit[ u.ss ] ) continue ;
        visit[u.ss] = 1 ;
        for ( auto v:G[u.ss] ) {
            if ( -u.ff + v.ss < sc[v.ff] ) sc[v.ff] = -u.ff + v.ss ;
            if ( fr[v.ff] > sc[v.ff] ) swap ( fr[v.ff], sc[v.ff] ) ;
            deg[v.ff]++ ;
            if ( deg[v.ff] >= 2 ) q.push ( make_pair(-sc[v.ff], v.ff) ) ;
        }
    }
    return sc[0] ;
}


# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 2688 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 2688 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 2688 KB Output isn't correct
2 Halted 0 ms 0 KB -