# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
976334 | kwongweng | Cyberland (APIO23_cyberland) | C++17 | 33 ms | 8788 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>
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
double solve(int N, int M, int K, int H, vi x, vi y, vi c, vi arr) {
vii g[N];
FOR(i,0,M){
g[x[i]].pb({y[i],c[i]});
g[y[i]].pb({x[i],c[i]});
}
vi used(N);
vi bfs; bfs.pb(0); used[0]=1;
FOR(i,0,bfs.size()){
int u = bfs[i]; if (u==H) continue;
for (ii edge : g[u]){
int v = edge.fi;
if (used[v]) continue;
bfs.pb(v); used[v]=1;
}
}
if (!used[H]) return -1;
vector<double> dist(N);
set<pair<double,int>> st;
st.insert({dist[0],0});
FOR(i,1,N){
if (arr[i]==0 && used[i]){
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});
}
}
}
return dist[H];
}
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... |