# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
670711 | 2022-12-09T22:23:06 Z | Stavab | Crocodile's Underground City (IOI11_crocodile) | C++14 | 1 ms | 212 KB |
#include "crocodile.h" #include <vector> #include <queue> #include <utility> using namespace std; #define INF 1999999999 vector<vector<pair<int, int>>> city; vector<int> times; vector<int> visited; int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]) { city.assign(N, vector<pair<int, int>>()); times.assign(N, INF); visited.assign(N, 0); for (int i = 0; i < N - 1; i++) { city[R[i][0]].push_back(make_pair(R[i][1], L[i])); city[R[i][1]].push_back(make_pair(R[i][0], L[i])); } priority_queue<pair<int, int>> pq; for (int i = 0; i < K; i++) { times[P[i]] = 0; visited[P[i]] = 1; for(int j = 0; j < city[P[i]].size(); j++) { if(!visited[city[P[i]][j].first]) pq.push(make_pair(city[P[i]][j].second, city[P[i]][j].first)); } } while(!pq.empty()) { int curTime = pq.top().first; int curNode = pq.top().second; if(times[curNode] == INF) times[curNode] = curTime; else { if(!visited[curNode]) { for(int j = 0; j < city[curNode].size(); j++) { if(!visited[city[curNode][j].first]) pq.push(make_pair(curTime + city[curNode][j].second, city[curNode][j].first)); } visited[curNode] = 1; times[curNode] = curTime; if(curNode == 0) return curTime; } } pq.pop(); } return -1; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 212 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 212 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 212 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |