Submission #71475

# Submission time Handle Problem Language Result Execution time Memory
71475 2018-08-24T19:52:12 Z RezwanArefin01 Crocodile's Underground City (IOI11_crocodile) C++17
100 / 100
1375 ms 104656 KB
#include <bits/stdc++.h>
#include "crocodile.h"
using namespace std;

typedef long long ll; 
typedef pair<ll, int> ii; 

const int N = 1e5 + 10; 
vector<int> adj[N], cost[N]; 
int vis[N];

int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]) {
    for(int i = 0; i < M; i++) {
        int u = R[i][0], v = R[i][1], c = L[i]; 
        adj[u].push_back(v);
        adj[v].push_back(u);
        cost[u].push_back(c);
        cost[v].push_back(c); 
    }
    priority_queue<ii, vector<ii>, greater<ii> > Q;  
    for(int i = 0; i < K; i++) {
        int u = P[i]; 
        vis[u] = 1; 
        Q.emplace(0, u); 
    }
    while(!Q.empty()) {
        ii x = Q.top(); Q.pop(); 
        int u = x.second; ll D = x.first; 
        vis[u]++; 
        if(vis[u] != 2) continue; 
        if(!u) return D; 
        for(int i = 0; i < adj[u].size(); i++)
           Q.emplace(D + cost[u][i], adj[u][i]);  
    }
}

Compilation message

crocodile.cpp: In function 'int travel_plan(int, int, int (*)[2], int*, int, int*)':
crocodile.cpp:32:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(int i = 0; i < adj[u].size(); i++)
                        ~~^~~~~~~~~~~~~~~
crocodile.cpp:35:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
# Verdict Execution time Memory Grader output
1 Correct 9 ms 4984 KB Output is correct
2 Correct 6 ms 5092 KB Output is correct
3 Correct 10 ms 5256 KB Output is correct
4 Correct 10 ms 5256 KB Output is correct
5 Correct 9 ms 5412 KB Output is correct
6 Correct 8 ms 5452 KB Output is correct
7 Correct 8 ms 5452 KB Output is correct
8 Correct 9 ms 5572 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 9 ms 4984 KB Output is correct
2 Correct 6 ms 5092 KB Output is correct
3 Correct 10 ms 5256 KB Output is correct
4 Correct 10 ms 5256 KB Output is correct
5 Correct 9 ms 5412 KB Output is correct
6 Correct 8 ms 5452 KB Output is correct
7 Correct 8 ms 5452 KB Output is correct
8 Correct 9 ms 5572 KB Output is correct
9 Correct 14 ms 5864 KB Output is correct
10 Correct 8 ms 5864 KB Output is correct
11 Correct 9 ms 5864 KB Output is correct
12 Correct 21 ms 6664 KB Output is correct
13 Correct 14 ms 6664 KB Output is correct
14 Correct 7 ms 6664 KB Output is correct
15 Correct 9 ms 6664 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 9 ms 4984 KB Output is correct
2 Correct 6 ms 5092 KB Output is correct
3 Correct 10 ms 5256 KB Output is correct
4 Correct 10 ms 5256 KB Output is correct
5 Correct 9 ms 5412 KB Output is correct
6 Correct 8 ms 5452 KB Output is correct
7 Correct 8 ms 5452 KB Output is correct
8 Correct 9 ms 5572 KB Output is correct
9 Correct 14 ms 5864 KB Output is correct
10 Correct 8 ms 5864 KB Output is correct
11 Correct 9 ms 5864 KB Output is correct
12 Correct 21 ms 6664 KB Output is correct
13 Correct 14 ms 6664 KB Output is correct
14 Correct 7 ms 6664 KB Output is correct
15 Correct 9 ms 6664 KB Output is correct
16 Correct 1277 ms 92004 KB Output is correct
17 Correct 150 ms 92004 KB Output is correct
18 Correct 177 ms 92004 KB Output is correct
19 Correct 1375 ms 102672 KB Output is correct
20 Correct 411 ms 102672 KB Output is correct
21 Correct 71 ms 102672 KB Output is correct
22 Correct 775 ms 104656 KB Output is correct