#include "cyberland.h"
#include <bits/stdc++.h>
using namespace std;
using ll = long double;
using vll = vector<ll>;
using vvll = vector<vll>;
const ll INF = 1e16;
vll v; vector<vector<pair<ll, ll>>>g;
ll h,n;
void dfs(ll x) {
if (v[x]++) return;
if ((int)x%(int)n==h) return;
for (auto i : g[x]) {
dfs(i.first);
}
}
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) {
ll m = M, k = min(K, 60) + 1; h = H, n = N;
v = vll(n * k); g = vector<vector<pair<ll, ll>>>(n * k);
for (ll j = 0; j < k; j++) {
for (ll i = 0; i < m; i++) {
g[x[i] + j * n].push_back({ y[i] + j * n, c[i] * 1.0 / (1ll << (long long)j) });
g[y[i] + j * n].push_back({ x[i] + j * n, c[i] * 1.0 / (1ll << (long long)j) });
if (j && arr[x[i]] == 2) {
g[x[i] + j * n].push_back({ y[i] + (j - 1) * n, c[i] * 1.0 / (1ll << (long long)j) });
}
if (j && arr[y[i]] == 2) {
g[y[i] + j * n].push_back({ x[i] + (j - 1) * n, c[i] * 1.0 / (1ll << (long long)j) });
}
}
}
for (ll i = 0; i < k; i++) {
dfs(i * n);
}
vll save = v;
v = vll(n * k, INF);
priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>> q;
for (ll i = 0; i < k; i++) {
q.push({ 0,i*n }); v[i*n] = 0;
}
for (ll j = 0; j < k; j++) {
for (ll i = 0; i < n; i++) {
if (arr[i] == 0&&save[i+j*n]) {
q.push({ 0, i + j * n });
v[i + j * n] = 0;
}
}
}
save = vll(n*k);
while (q.size()) {
ll ce= q.top().second; q.pop();
if (((int)ce%(int)n)==h) {
continue;
}
if (!save[ce]++) {
for (auto i : g[ce]) {
if (v[i.first] > v[ce] + i.second) {
v[i.first] = v[ce] + i.second;
q.push({ v[i.first],i.first });
}
}
}
}
if (v[h] >= INF) {
return -1;
}
return v[h];
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
250 ms |
592 KB |
Wrong Answer. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
767 ms |
5504 KB |
Correct. |
2 |
Correct |
908 ms |
6044 KB |
Correct. |
3 |
Correct |
870 ms |
5504 KB |
Correct. |
4 |
Correct |
893 ms |
5908 KB |
Correct. |
5 |
Correct |
892 ms |
5700 KB |
Correct. |
6 |
Correct |
921 ms |
53116 KB |
Correct. |
7 |
Correct |
1214 ms |
47636 KB |
Correct. |
8 |
Correct |
504 ms |
96340 KB |
Correct. |
9 |
Correct |
777 ms |
1136 KB |
Correct. |
10 |
Correct |
760 ms |
1108 KB |
Correct. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1196 ms |
6260 KB |
Correct. |
2 |
Correct |
1173 ms |
6664 KB |
Correct. |
3 |
Correct |
1092 ms |
6168 KB |
Correct. |
4 |
Correct |
1054 ms |
1340 KB |
Correct. |
5 |
Correct |
1046 ms |
1440 KB |
Correct. |
6 |
Correct |
257 ms |
43776 KB |
Correct. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
755 ms |
322320 KB |
Wrong Answer. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
488 ms |
6064 KB |
Correct. |
2 |
Correct |
536 ms |
5924 KB |
Correct. |
3 |
Correct |
553 ms |
5648 KB |
Correct. |
4 |
Correct |
677 ms |
46044 KB |
Correct. |
5 |
Correct |
452 ms |
1056 KB |
Correct. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
810 ms |
6196 KB |
Correct. |
2 |
Correct |
654 ms |
5940 KB |
Correct. |
3 |
Correct |
1002 ms |
376824 KB |
Correct. |
4 |
Correct |
589 ms |
44296 KB |
Correct. |
5 |
Correct |
724 ms |
1252 KB |
Correct. |
6 |
Correct |
750 ms |
6008 KB |
Correct. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
815 ms |
6632 KB |
Wrong Answer. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1630 ms |
12504 KB |
Wrong Answer. |
2 |
Halted |
0 ms |
0 KB |
- |