#include <bits/stdc++.h>
#include "cyberland.h"
using namespace std;
using ll = long long;
#define ff first
#define ss second
#define pii pair<int, int>
double solve(int n, int M, int K, int H, vector<int> X, vector<int> Y, vector<int> C, vector<int> a) {
vector<pii> E[n];
for (int i = 0; i < M; i++) {
E[X[i]].push_back({Y[i], C[i]});
E[Y[i]].push_back({X[i], C[i]});
}
queue<int> q;
vector<bool> vis0(n);
q.push(0); vis0[0] = true;
while (!q.empty()) {
int x = q.front(); q.pop();
for (auto [i, w] : E[x]) {
if (!vis0[i]) {
q.push(i);
vis0[i] = true;
}
}
}
vector<ll> dis(n, LLONG_MAX);
priority_queue<pair<ll, int>> pq;
dis[H] = 0; pq.push({0, H});
while (!pq.empty()) {
auto [d, x] = pq.top(); d = -d; pq.pop();
if (d != dis[x]) continue;
for (auto [i, w] : E[x]) {
if (d + w < dis[i]) {
dis[i] = d + w;
pq.push({-dis[i], i});
}
}
}
if (dis[0] == LLONG_MAX) return -1;
ll ans = dis[0];
for (int i = 1; i < n; i++) {
if (!a[i] && vis0[i]) ans = min(ans, dis[i]);
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
11 ms |
600 KB |
Wrong Answer. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
15 ms |
600 KB |
Correct. |
2 |
Correct |
18 ms |
604 KB |
Correct. |
3 |
Correct |
18 ms |
604 KB |
Correct. |
4 |
Correct |
18 ms |
572 KB |
Correct. |
5 |
Correct |
18 ms |
600 KB |
Correct. |
6 |
Correct |
16 ms |
1624 KB |
Correct. |
7 |
Correct |
20 ms |
1372 KB |
Correct. |
8 |
Correct |
9 ms |
2396 KB |
Correct. |
9 |
Correct |
19 ms |
348 KB |
Correct. |
10 |
Correct |
23 ms |
348 KB |
Correct. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
18 ms |
348 KB |
Wrong Answer. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
20 ms |
5720 KB |
Wrong Answer. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
15 ms |
600 KB |
Correct. |
2 |
Correct |
17 ms |
348 KB |
Correct. |
3 |
Correct |
17 ms |
544 KB |
Correct. |
4 |
Correct |
16 ms |
1356 KB |
Correct. |
5 |
Correct |
14 ms |
348 KB |
Correct. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
17 ms |
604 KB |
Wrong Answer. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
17 ms |
348 KB |
Wrong Answer. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
17 ms |
344 KB |
Wrong Answer. |
2 |
Halted |
0 ms |
0 KB |
- |