#pragma GCC diagnostic warning "-std=c++11"
#include <bits/stdc++.h>
#include "cyberland.h"
#define pb push_back
#define f first
#define s second
#define MOD 1000000007
#define flush fflush(stdout)
#define all(x) (x).begin(),(x).end()
#define allr(x) (x).rbegin(), (x).rend()
#define pii pair<int,int>
using namespace std;
const int N=1e5+5;
long long n,m,T,k,h,dist[N],fix[N],cr[N],st,big=1e18;
vector<pii> g[N];
double solve(int N, int M, int K, int H, vector<int> x, vector<int> y, vector<int> c, vector<int> arr) {
arr[0]=0; n=N; m=M; k=K; h=H;
for (int i=0; i<n; i++) {
g[i].clear();
cr[i]=0;
}
for (int i=0; i<m; i++) {
g[x[i]].pb({y[i],c[i]});
g[y[i]].pb({x[i],c[i]});
}
// st=0;
// for (int i=0; i<n; i++) dist[i]=1e18;
// for (int i=0; i<n; i++) fix[i]=0;
// dist[st]=0;
// // dif
// fix[h]=1;
// // dif
priority_queue<pii> q; //q.push({0,st});
// while (!q.empty()) {
// int v=q.top().s; q.pop();
// if (fix[v]) continue;
// fix[v]=1;
// for (auto X:g[v]) {
// int u=X.f,w=X.s;
// if (dist[u]>dist[v]+w) {
// dist[u]=dist[v]+w;
// q.push({-dist[u],u});
// }
// }
// }
//
for (int i=0; i<n; i++) {
// if (dist[i]<big) cr[i]=1;
cr[i]=1;
}
st=h;
for (int i=0; i<n; i++) dist[i]=1e18;
for (int i=0; i<n; i++) fix[i]=0;
dist[st]=0;
q.push({0,st});
while (!q.empty()) {
int v=q.top().s; q.pop();
if (fix[v]) continue;
fix[v]=1;
for (auto X:g[v]) {
int u=X.f,w=X.s;
if (dist[u]>dist[v]+w) {
dist[u]=dist[v]+w;
q.push({-dist[u],u});
}
}
}
long long ans=dist[0];
// long long ans=big;
// for (int i=0; i<n; i++) {
// if (cr[i] && arr[i]==0) ans=min(ans,dist[i]);
// }
double anss=ans;
if (ans==big) return -1;
return anss;
}
Compilation message (stderr)
cyberland.cpp:1:32: warning: '-std=c++11' is not an option that controls warnings [-Wpragmas]
1 | #pragma GCC diagnostic warning "-std=c++11"
| ^~~~~~~~~~~~
# | 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... |