Submission #240454

# Submission time Handle Problem Language Result Execution time Memory
240454 2020-06-19T16:49:58 Z oscarsierra12 Crocodile's Underground City (IOI11_crocodile) C++14
100 / 100
1022 ms 64608 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])) ;
    priority_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.top() ;
        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 Correct 6 ms 2688 KB Output is correct
2 Correct 6 ms 2688 KB Output is correct
3 Correct 6 ms 2688 KB Output is correct
4 Correct 7 ms 2816 KB Output is correct
5 Correct 7 ms 2816 KB Output is correct
6 Correct 7 ms 2816 KB Output is correct
7 Correct 7 ms 2816 KB Output is correct
8 Correct 7 ms 2816 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 2688 KB Output is correct
2 Correct 6 ms 2688 KB Output is correct
3 Correct 6 ms 2688 KB Output is correct
4 Correct 7 ms 2816 KB Output is correct
5 Correct 7 ms 2816 KB Output is correct
6 Correct 7 ms 2816 KB Output is correct
7 Correct 7 ms 2816 KB Output is correct
8 Correct 7 ms 2816 KB Output is correct
9 Correct 10 ms 3016 KB Output is correct
10 Correct 6 ms 2688 KB Output is correct
11 Correct 7 ms 2816 KB Output is correct
12 Correct 13 ms 3328 KB Output is correct
13 Correct 12 ms 3328 KB Output is correct
14 Correct 6 ms 2688 KB Output is correct
15 Correct 7 ms 2816 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 2688 KB Output is correct
2 Correct 6 ms 2688 KB Output is correct
3 Correct 6 ms 2688 KB Output is correct
4 Correct 7 ms 2816 KB Output is correct
5 Correct 7 ms 2816 KB Output is correct
6 Correct 7 ms 2816 KB Output is correct
7 Correct 7 ms 2816 KB Output is correct
8 Correct 7 ms 2816 KB Output is correct
9 Correct 10 ms 3016 KB Output is correct
10 Correct 6 ms 2688 KB Output is correct
11 Correct 7 ms 2816 KB Output is correct
12 Correct 13 ms 3328 KB Output is correct
13 Correct 12 ms 3328 KB Output is correct
14 Correct 6 ms 2688 KB Output is correct
15 Correct 7 ms 2816 KB Output is correct
16 Correct 951 ms 64608 KB Output is correct
17 Correct 101 ms 14584 KB Output is correct
18 Correct 135 ms 15992 KB Output is correct
19 Correct 1022 ms 63980 KB Output is correct
20 Correct 691 ms 53864 KB Output is correct
21 Correct 53 ms 7928 KB Output is correct
22 Correct 592 ms 46328 KB Output is correct