#include <bits/stdc++.h>
using namespace std;
struct node {
vector<pair<node*, int>> l;
long long f = -1;
bool g;
};
void gfs(node* n, node* p){
for(auto [c, co] : n->l){
if(c!=p) gfs(c, n);
n->g |= c->g;
}
}
void dfs(node* n, node* p){
for(auto [c, co] : n->l){
if(c != p){
c->f = n->f + co;
dfs(c, n);
}
}
}
double solve(int N, int M, int K, int H, std::vector<int> x, std::vector<int> y, std::vector<int> c, std::vector<int> arr){
node g[N];
g[0].g =true;
for(int i = 0;i < M;i++){
g[x[i]].l.emplace_back(&g[y[i]], c[i]);
g[y[i]].l.emplace_back(&g[x[i]], c[i]);
}
g[H].f = 0;
dfs(&g[H], NULL);
// gfs(&g[H], NULL);
// for(auto [c, co] : g[H].l){
// if(c->g) {
// c->f = co;
// dfs(c, &g[H]);
// }
// }
long long ans = g[0].f;
for(int i = 0;i < N;i++){
if(!arr[i] && g[i].f != -1) ans = min(ans, g[i].f);
}
return ans;
}
// int main(){
// cout << solve(3, 2, 30, 2, {1, 2}, {2, 0}, {12, 4}, {1, 2, 1}) << '\n';
// }
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
2171 ms |
2097152 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
17 ms |
764 KB |
Correct. |
2 |
Correct |
25 ms |
1184 KB |
Correct. |
3 |
Correct |
19 ms |
1200 KB |
Correct. |
4 |
Correct |
19 ms |
1172 KB |
Correct. |
5 |
Correct |
27 ms |
1224 KB |
Correct. |
6 |
Correct |
15 ms |
2252 KB |
Correct. |
7 |
Correct |
20 ms |
2232 KB |
Correct. |
8 |
Correct |
9 ms |
3028 KB |
Correct. |
9 |
Correct |
18 ms |
1076 KB |
Correct. |
10 |
Correct |
18 ms |
1216 KB |
Correct. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
19 ms |
1208 KB |
Wrong Answer. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
38 ms |
9028 KB |
Wrong Answer. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1030 ms |
2097152 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1053 ms |
2097152 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1116 ms |
2097152 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1044 ms |
2097152 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |