#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;
vector<pii> adj[N];
int a[N];
ll dis[N];
void dfs(int x, int pr = -1){
for(auto [i, w] : adj[x])
if(i != pr){
dis[i] = dis[x]+w;
if(a[i] == 0)
dis[i] = 0;
dfs(i, x);
}
}
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 < n; ++i)
a[i] = arr[i];
for(int i = 0; i < m; ++i){
adj[u[i]].pb({v[i], w[i]});
adj[v[i]].pb({u[i], w[i]});
}
for(int i = 0; i <= n; ++i)
dis[i] = 0;
// I will make 0 root
dfs(0);
// you can always go to the h from the root(0), because this is tree
double answer = 0;
answer += dis[h];
for(int i = 0; i <= n; ++i)
adj[i].clear();
return answer;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1191 ms |
2097152 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
11 ms |
3928 KB |
Correct. |
2 |
Correct |
14 ms |
4956 KB |
Correct. |
3 |
Correct |
12 ms |
4932 KB |
Correct. |
4 |
Correct |
14 ms |
4952 KB |
Correct. |
5 |
Correct |
15 ms |
4960 KB |
Correct. |
6 |
Correct |
13 ms |
5236 KB |
Correct. |
7 |
Correct |
15 ms |
5468 KB |
Correct. |
8 |
Correct |
8 ms |
5724 KB |
Correct. |
9 |
Correct |
13 ms |
4700 KB |
Correct. |
10 |
Correct |
13 ms |
4716 KB |
Correct. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
13 ms |
3932 KB |
Wrong Answer. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
20 ms |
11112 KB |
Wrong Answer. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1085 ms |
2097152 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1142 ms |
2097152 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1117 ms |
2097152 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1185 ms |
2097152 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |