# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
697292 | 2023-02-09T06:33:59 Z | vjudge1 | Crocodile's Underground City (IOI11_crocodile) | C++11 | 2 ms | 2644 KB |
#include<iostream> #include<vector> #include<queue> using namespace std; const long long maxn = 100005; const long long maxv = (long long) 1e18; long long n,m,k,val[maxn][2]; bool beenTo[maxn]; vector<pair<long long,long long> > conn[maxn]; priority_queue<pair<long long,long long>,vector<pair<long long,long long> >,greater<pair<long long,long long> > > dijkstra; int travel_plan(int N, int M, int R[][2], int W[], int K, int E[]) { n = N; m = M; k = K; for(int i = 0; i < m; i++) { int a = R[i][0]; int b = R[i][1]; int c = W[i]; conn[a].push_back(make_pair(c,b)); conn[b].push_back(make_pair(c,a)); } for(int i = 0; i < k; i++) { int a = E[i]; val[a][0] = 0; val[a][1] = 0; dijkstra.push(make_pair(0,a)); } for(long long i = 0; i < n; i++) { val[i][0] = maxv; val[i][1] = maxv; } while(dijkstra.size() > 0) { pair<long long,long long> curr = dijkstra.top(); dijkstra.pop(); if(beenTo[curr.second] == true) continue; beenTo[curr.second] = true; for(long long i = 0; i < conn[curr.second].size(); i++) { pair<long long,long long> targ = conn[curr.second][i]; if(val[targ.second][0] > val[curr.second][1]+targ.first) { val[targ.second][1] = val[targ.second][0]; val[targ.second][0] = val[curr.second][1]+targ.first; dijkstra.push(make_pair(val[targ.second][1],targ.second)); } else if(val[targ.second][1] > val[curr.second][1]+targ.first) { val[targ.second][1] = val[curr.second][1]+targ.first; dijkstra.push(make_pair(val[targ.second][1],targ.second)); } } } return val[0][1]; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 2644 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 2644 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 2644 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |