#include "cyberland.h"
#include <bits/stdc++.h>
using namespace std;
#define scd(t) scanf("%d", &t)
#define sclld(t) scanf("%lld", &t)
#define forr(i, j, k) for (int i = j; i < k; i++)
#define frange(i, j) forr(i, 0, j)
#define all(cont) cont.begin(), cont.end()
#define mp make_pair
#define pb push_back
#define f first
#define s second
typedef long long int lli;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<lli> vll;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef vector<vi> vvi;
typedef map<int, int> mpii;
typedef set<int> seti;
typedef multiset<int> mseti;
typedef long double ld;
vector<vii> graph;
vb vis;
void dfs(int x) {
if(vis[x]) return;
vis[x] = true;
for(auto e : graph[x]) dfs(e.f);
}
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) {
graph = vector<vii>(n);
frange(i, m) {
int a=x[i];int b = y[i];
if(a != h) graph[a].pb(mp(b, c[i]));
if(b != h) graph[b].pb(mp(a, c[i]));
}
vis = vb(n);
dfs(0);
vector<vector<ld>> dist(k+1, vector<ld>(n, 1e15));
vector<vb> vis2(k+1, vb(n));
dist[0][0] = 0;
priority_queue<pair<ld, pii>> pq;
pq.push(mp(0, mp(0, 0)));
forr(i, 1, n) {
if(vis[i] && arr[i] == 0) {
dist[0][i] = 0;
pq.push(mp(0, mp(i, 0)));
}
}
while(pq.size()) {
auto p = pq.top();
pq.pop();
int x = p.s.f;
int c = p.s.s;
ld w = -p.f;
if(vis2[c][x]) continue;
vis2[c][x] = true;
for(auto e : graph[x]) {
if(dist[c][e.f] > w + e.s) {
dist[c][e.f] = w + e.s;
pq.push(mp(-dist[c][e.f], mp(e.f, c)));
}
if(c<k && arr[e.f]==2 && dist[c+1][e.f] > ld(w+e.s)/2) {
dist[c+1][e.f] = ld(w+e.s)/2;
pq.push(mp(-dist[c+1][e.f], mp(e.f, c+1)));
}
}
}
ld mi = 1e15;
frange(i, k+1) mi = min(mi, dist[i][h]);
if(abs(mi-1e15)<=1) return -1;
else
return mi;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
46 ms |
596 KB |
Correct. |
2 |
Correct |
44 ms |
860 KB |
Correct. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
26 ms |
1268 KB |
Correct. |
2 |
Correct |
31 ms |
1128 KB |
Correct. |
3 |
Correct |
29 ms |
1056 KB |
Correct. |
4 |
Correct |
31 ms |
1096 KB |
Correct. |
5 |
Correct |
31 ms |
1104 KB |
Correct. |
6 |
Correct |
28 ms |
6140 KB |
Correct. |
7 |
Correct |
37 ms |
5992 KB |
Correct. |
8 |
Correct |
16 ms |
12124 KB |
Correct. |
9 |
Correct |
27 ms |
600 KB |
Correct. |
10 |
Correct |
28 ms |
604 KB |
Correct. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
36 ms |
1360 KB |
Correct. |
2 |
Correct |
32 ms |
2012 KB |
Correct. |
3 |
Correct |
30 ms |
1356 KB |
Correct. |
4 |
Correct |
30 ms |
1616 KB |
Correct. |
5 |
Correct |
31 ms |
1640 KB |
Correct. |
6 |
Correct |
7 ms |
5464 KB |
Correct. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
179 ms |
40056 KB |
Correct. |
2 |
Incorrect |
203 ms |
2432 KB |
Wrong Answer. |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
26 ms |
1052 KB |
Correct. |
2 |
Correct |
29 ms |
1048 KB |
Correct. |
3 |
Correct |
28 ms |
1064 KB |
Correct. |
4 |
Correct |
28 ms |
6120 KB |
Correct. |
5 |
Correct |
25 ms |
604 KB |
Correct. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
28 ms |
1104 KB |
Correct. |
2 |
Correct |
25 ms |
1836 KB |
Correct. |
3 |
Correct |
51 ms |
47188 KB |
Correct. |
4 |
Correct |
22 ms |
4952 KB |
Correct. |
5 |
Correct |
27 ms |
1492 KB |
Correct. |
6 |
Correct |
27 ms |
1972 KB |
Correct. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
236 ms |
1712 KB |
Wrong Answer. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1067 ms |
2097152 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |