#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef long double ld;
typedef tree <int, null_type, less<int>, rb_tree_tag,
tree_order_statistics_node_update> ordered_set;
typedef pair<double, int> pii;
#define nl '\n'
#define vt vector
#define ar array
#define pb push_back
#define ff first
#define ss second
const int INF = INT_MAX;
double solve(int N, int M, int K, int H, vt<int> x, vt<int> y, vt<int> c, vt<int> arr) {
int n = N, m = M, k = K, h = H;
vt<pair<int, int>> adj[n];
for(int i = 0; i < m; i++) {
adj[x[i]].pb({y[i], c[i]});
adj[y[i]].pb({x[i], c[i]});
}
vector<double> d(n, numeric_limits<double>::max());
priority_queue<pii, vt<pii>, greater<pii>> q;
d[0] = 0;
q.push({0, 0});
while(!q.empty()) {
int u = q.top().ss;
double res = q.top().ff;
q.pop();
if(u == h) return res;
int ch = k;
if(arr[u] == 2) ch--;
for(auto &edge : adj[u]) {
int v = edge.ff;
int c = edge.ss;
double nw = res + c;
if(arr[v] == 0) nw = res;
if(arr[v] == 2 && ch--)
nw = res + c / 2.;
if(nw <= d[v]) {
d[v] = nw;
q.push({nw, v});
}
}
}
return -1;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
14 ms |
600 KB |
Correct. |
2 |
Correct |
14 ms |
820 KB |
Correct. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
21 ms |
604 KB |
Correct. |
2 |
Correct |
24 ms |
584 KB |
Correct. |
3 |
Correct |
19 ms |
604 KB |
Correct. |
4 |
Correct |
20 ms |
564 KB |
Correct. |
5 |
Correct |
20 ms |
760 KB |
Correct. |
6 |
Correct |
15 ms |
1624 KB |
Correct. |
7 |
Correct |
22 ms |
1212 KB |
Correct. |
8 |
Correct |
10 ms |
2396 KB |
Correct. |
9 |
Correct |
18 ms |
348 KB |
Correct. |
10 |
Correct |
22 ms |
344 KB |
Correct. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3087 ms |
525872 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3099 ms |
270624 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
18 ms |
604 KB |
Correct. |
2 |
Correct |
20 ms |
348 KB |
Correct. |
3 |
Correct |
20 ms |
344 KB |
Correct. |
4 |
Correct |
18 ms |
1368 KB |
Correct. |
5 |
Correct |
17 ms |
344 KB |
Correct. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3114 ms |
526548 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3065 ms |
527864 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3025 ms |
527820 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |