# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
758261 | 2023-06-14T10:21:09 Z | ivaziva | Crocodile's Underground City (IOI11_crocodile) | C++14 | 0 ms | 340 KB |
#include "crocodile.h" #include <bits/stdc++.h> using namespace std; #define MAXN 1010 int travel_plan(int N,int M,int R[][2],int L[],int K,int P[]) { long long n; long long m; long long k; vector<pair<long long,long long>> adj[MAXN]; long long niz[MAXN]; long long dist1[MAXN]; long long dist2[MAXN]; long long pos[MAXN]; n=N; m=M; k=K; for (long long i=0;i<m;i++) { long long x=R[i][0]; long long y=R[i][1]; long long z=L[i]; adj[x].push_back({y,z}); adj[y].push_back({x,z}); } for (long long i=0;i<MAXN;i++) { dist1[i]=LLONG_MAX; dist2[i]=LLONG_MAX; } priority_queue<pair<long long,long long>,vector<pair<long long,long long>>,greater<pair<long long,long long>>> pq; for (long long i=0;i<k;i++) { niz[i+1]=P[i-1]; pq.push({0,niz[i+1]}); dist1[niz[i+1]]=0; dist2[niz[i+1]]=0; pos[niz[i+1]]=1; } while (pq.empty()==false) { long long node0=pq.top().second; long long dist0=pq.top().first; pq.pop(); if (dist0>dist2[node0]) continue; if (pos[node0]>1) continue; long long s=adj[node0].size(); for (long long i=0;i<s;i++) { long long node=adj[node0][i].first; long long dist=adj[node0][i].second; if (dist0+dist<dist1[node]) { dist2[node]=dist1[node]; dist1[node]=dist0+dist; pq.push({dist1[node],node}); } else if (dist0+dist<dist2[node]) { dist2[node]=dist0+dist; pq.push({dist2[node],node}); } } pos[node0]++; } return (int)dist2[0]; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 340 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 340 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 340 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |