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"
using namespace std;
#define ff first
#define ss second
#define all(v) v.begin(), v.end()
#define ll long long
#define pb push_back
#define pii pair<int, int>
#define wr puts("----------------")
template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
const int N = 1e5+5;
const ll INF = 1e15; // 1e5*1e9=1e14
vector<pii> adj[N];
double d[N];
bool vis[N];
double solve(int n, int m, int k, int h, vector<int> u, vector<int> v, vector<int> w, vector<int> arr){
for(int i = 0; i < m; ++i){
adj[u[i]].pb({v[i], w[i]});
adj[v[i]].pb({u[i], w[i]});
}
memset(vis, false, sizeof vis);
memset(d, -1, sizeof d);
queue<int> q;
q.push(0);
d[0] = 0;
vis[0] = true;
while(!q.empty()){
int x = q.front();
q.pop();
for(auto [i, val] : adj[x])
if(!vis[i]){
vis[i] = true;
d[i] = d[x]+val;
if(!arr[i])
d[i] = 0;
q.push(i);
}
}
for(int i = 0; i <= n; ++i)
adj[i].clear();
double answer = 0;
answer += d[h];
return answer;
}
// int main(){
// double kk = solve(5, 4, 10, 4, {0, 0, 2, 2}, {1, 2, 3, 4}, {6, 5, 7, 8}, {1, 1, 0, 1, 0});
// printf("%f\n", kk);
// return 0;
// }
# | 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... |