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>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef long double ld;
typedef vector<vector<ll>> vll;
#define FOR(i, a, b) for(int i = a; i < b; i++)
#define ROF(i, a, b) for(int i = a; i >= b; i--)
#define pb push_back
#define ms memset
#define fi first
#define se second
const int mxn = 1e5;
vii g[mxn];
double solve(int N, int M, int K, int H, vi x, vi y, vi c, vi arr) {
FOR(i,0,M){
g[x[i]].pb({y[i],c[i]});
g[y[i]].pb({x[i],c[i]});
}
vector<ll> dist(N);
set<pair<ll,ll>> st;
st.insert({dist[0],0});
FOR(i,1,N){
if (arr[i]==0){
st.insert({dist[i],i});
}else{
dist[i] = 1e18;
}
}
while (!st.empty()){
int u = (*st.begin()).se; st.erase(st.begin());
for (ii edge : g[u]){
int v = edge.fi; int w = edge.se;
if (dist[v] > dist[u] + w){
st.erase({dist[v],v});
dist[v] = dist[u]+w;
st.insert({dist[v],v});
}
}
}
if (dist[H]==1e18) return -1;
return (double)dist[H];
}
# | 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... |