# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
984833 | IUA_Hasin | Cyberland (APIO23_cyberland) | C++17 | 33 ms | 16724 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 "cyberland.h"
#include <bits/stdc++.h>
#define endl "\n"
#define yeap cout<<"YES"<<endl
#define nope cout<<"NO"<<endl
#define ll long long
#define ld long double
using namespace std;
const ll M = 3e5+5;
const ll INF = 5e16+69;
vector<pair<ll, ll>> graph[M];
vector<ll> dist(M, INF);
ll vis[M];
void dijkstra(ll source){
set<pair<ll, ll>> s;
s.insert({0, source});
dist[source] = 0;
while(s.size()>0){
auto node = *s.begin();
ll v = node.second;
ll v_dist = node.first;
s.erase(s.begin());
if(vis[v]==0){
for(auto child : graph[v]){
ll v2 = child.first;
ll wt = child.second;
if((dist[v]+wt)<(dist[v2])){
dist[v2] = dist[v]+wt;
s.insert({dist[v2], v2});
}
}
vis[v] = 1;
}
}
}
double solve(int N, int M, int K, int H, std::vector<int> x, std::vector<int> y, std::vector<int> c, std::vector<int> arr) {
for(int i=0; i<=N; i++){
graph[i].clear();
dist[i] = INF;
vis[i] = 0;
}
for(int i=0; i<x.size(); i++){
ll a = x[i];
ll b = y[i];
ll wt = c[i];
graph[a].push_back({b, wt});
graph[b].push_back({a, wt});
}
dijkstra(0);
ll ans = dist[H];
if(dist[H]==INF){
return -1;
} else {
return ans;
}
}
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... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |