Submission #126627

# Submission time Handle Problem Language Result Execution time Memory
126627 2019-07-08T07:51:58 Z DodgeBallMan Crocodile's Underground City (IOI11_crocodile) C++14
0 / 100
4 ms 2808 KB
#include <bits/stdc++.h>
#include "crocodile.h"
#define pii pair<int, long long>
#define x first
#define y second 

using namespace std;

const int N = 1e5 + 10;
long long cnt[N];
vector<pii> g[N];
priority_queue< pii, vector<pii>, greater<pii> > q; 

int travel_plan( int n, int m, int r[][2], int l[], int k, int p[] ) 
{
    for( int i = 0 ; i < m ; i++ ) {
        g[r[i][0]].emplace_back( r[i][1], ( long long )l[i] );
        g[r[i][1]].emplace_back( r[i][0], ( long long )l[i] );
    }
    for( int i = 0 ; i < k ; i++ ) {
        cnt[p[i]]++;
        q.push( pii( p[i], 0 ) );
    }
    while( !q.empty() ) {
        pii te = q.top(); q.pop();
        cnt[te.x]++;
        if( cnt[te.x] != 2 ) continue ;
        if( te.x == 0 ) return te.y;
        for( pii i : g[te.x] ) if( cnt[i.x] < 2 ) {
            q.push( pii( i.x, i.y + te.y ) );
        }
    }
}           

Compilation message

crocodile.cpp: In function 'int travel_plan(int, int, int (*)[2], int*, int, int*)':
crocodile.cpp:33:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 2808 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 2808 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 2808 KB Output isn't correct
2 Halted 0 ms 0 KB -