Submission #408949

# Submission time Handle Problem Language Result Execution time Memory
408949 2021-05-19T21:31:25 Z SirCovidThe19th Crocodile's Underground City (IOI11_crocodile) C++14
100 / 100
565 ms 77060 KB
#include <bits/stdc++.h>
using namespace std;
 
int travel_plan(int n, int m, int r[][2], int l[], int k, int p[]){
    vector<vector<pair<int, int>>> adj(n);
    for (int i = 0; i < m; i++){
        adj[r[i][0]].push_back({l[i], r[i][1]});
        adj[r[i][1]].push_back({l[i], r[i][0]});
    }
    priority_queue<pair<long long, int>> trav;
    vector<int> visited(n, 0);
    for (int i = 0; i < k; i++){
        visited[p[i]] = 1;
        trav.push({0, p[i]});
    }
    while (!trav.empty()){
        pair<long long, int> curr = trav.top(); trav.pop();
        visited[curr.second]++;
        if (visited[curr.second] == 2 and curr.second == 0) 
            return -curr.first;
        if (visited[curr.second] == 2)
            for (pair<int, int> elem : adj[curr.second])
                if (visited[elem.second] != 2)
                    trav.push({curr.first-elem.first, elem.second});
    }
}

Compilation message

crocodile.cpp: In function 'int travel_plan(int, int, int (*)[2], int*, int, int*)':
crocodile.cpp:5:41: warning: control reaches end of non-void function [-Wreturn-type]
    5 |     vector<vector<pair<int, int>>> adj(n);
      |                                         ^
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 300 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 2 ms 436 KB Output is correct
5 Correct 2 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 2 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 300 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 2 ms 436 KB Output is correct
5 Correct 2 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 2 ms 332 KB Output is correct
9 Correct 3 ms 588 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 2 ms 460 KB Output is correct
12 Correct 6 ms 1104 KB Output is correct
13 Correct 4 ms 1228 KB Output is correct
14 Correct 1 ms 300 KB Output is correct
15 Correct 2 ms 436 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 300 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 2 ms 436 KB Output is correct
5 Correct 2 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 2 ms 332 KB Output is correct
9 Correct 3 ms 588 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 2 ms 460 KB Output is correct
12 Correct 6 ms 1104 KB Output is correct
13 Correct 4 ms 1228 KB Output is correct
14 Correct 1 ms 300 KB Output is correct
15 Correct 2 ms 436 KB Output is correct
16 Correct 535 ms 77060 KB Output is correct
17 Correct 84 ms 13248 KB Output is correct
18 Correct 96 ms 14776 KB Output is correct
19 Correct 548 ms 64676 KB Output is correct
20 Correct 352 ms 56528 KB Output is correct
21 Correct 47 ms 5832 KB Output is correct
22 Correct 565 ms 36892 KB Output is correct