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 "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef long double ld;
typedef tree <int, null_type, less<int>, rb_tree_tag,
tree_order_statistics_node_update> ordered_set;
#define nl '\n'
#define vt vector
#define ar array
#define pb push_back
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
const int INF = 1e9;
vt<vt<pair<int, int>>> adj;
void dfs(int s, vt<double> &d) {
int n = adj.size();
d.assign(n, INF);
vt<bool> u(n, 0);
d[s] = 0;
for(int i = 0; i < n; i++) {
int v = -1;
for(int j = 0; j < n; j++) {
if(!u[j] && (v == -1 || d[j] < d[v]))
v = j;
}
if(d[v] == INF)
break;
u[v] = 1;
for(auto edge : adj[v]) {
int to = edge.ff;
int len = edge.ss;
d[to] = min(d[to], d[v] + len);
}
}
}
double solve(int N, int M, int K, int H, vt<int> x, vt<int> y, vt<int> c, vt<int> arr) {
adj.resize(N);
for(int i = 0; i < M; i++) {
adj[x[i]].pb({y[i], c[i]});
adj[y[i]].pb({x[i], c[i]});
}
vt<double> d(N);
dfs(0, d);
return d[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... |