# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1082066 | CELD_07 | Crocodile's Underground City (IOI11_crocodile) | C++17 | 362 ms | 93356 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "crocodile.h"
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#define ll long long
#define endl "\n"
#define inf 1e15
#define vll vector<ll>
#define sd second
#define ft first
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define pll pair<ll, ll>
#define mod 1000000007
#define _set tree<pll, null_type, less<pll>, rb_tree_tag, tree_order_statistics_node_update>
using namespace std;
using namespace __gnu_pbds;
vector<vector<pair<ll, ll>>> adj;
vector<pair<ll, ll>> dist;
vector<bool> visited;
inline void dijkstra(int g[], int k){
priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>> pq;
for(int i=0; i<k; i++)pq.push({0, g[i]}), dist[g[i]]={0, 0};
while(!pq.empty()){
ll o, o1;
tie(o, o1)=pq.top();
pq.pop();
if(visited[o1])continue;
visited[o1]=1;
for(auto& [y, w]: adj[o1]){
if(o+w<dist[y].ft){
dist[y].sd=dist[y].ft;
dist[y].ft=o+w;
pq.push({dist[y].sd, y});
}else if(dist[y].sd>o+w){
dist[y].sd=o+w;
pq.push({dist[y].sd, y});
}
}
}
}
int travel_plan(int N, int M, int R[][2], int W[], int K, int E[]){
ll a, b, c, d, e;
adj.clear();
dist.clear();
visited.clear();
visited.assign(N+1, 0);
adj.resize(N+1);
dist.assign(N+1, {inf, inf});
for(int i=0; i<M; i++){
adj[R[i][0]].push_back({R[i][1], W[i]});
adj[R[i][1]].push_back({R[i][0], W[i]});
}
dijkstra(E, K);
return dist[0].sd;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |