#include "cyberland.h"
#include <bits/stdc++.h>
using namespace std;
const int ZERO = 0;
const int NORMAL = 1;
const int DIV2 = 2;
void upMin(double res, double val) {
if (res < 0) res = val;
else res = min(res, val);
}
double sub1(
int n, int m, int maxDiv2, int target,
const vector<int>& edge_froms,
const vector<int>& edge_tos,
const vector<int>& edge_costs,
const vector<int>& node_types) {
vector<vector<int>> costs(n, vector<int> (n, -1));
for (int i = 0; i < m; ++i) {
int u = edge_froms[i];
int v = edge_tos[i];
costs[u][v] = costs[v][u] = edge_costs[i];
}
double res = -1;
// go directly from 0 -> target
if (costs[0][target] >= 0)
upMin(res, costs[0][target]);
// go 0 -> other vertex -> target
int other = 3 - target;
if (costs[0][other] >= 0 && costs[other][target] >= 0) {
switch (node_types[other]) {
case NORMAL:
upMin(res, costs[0][other] + costs[other][target]);
break;
case ZERO:
upMin(res, costs[other][target]);
break;
case DIV2:
upMin(res, costs[0][other] / 2.0 + costs[other][target]);
break;
}
}
return res;
}
double solve(
int n, int m, int maxDiv2, int target,
vector<int> edge_froms,
vector<int> edge_tos,
vector<int> edge_costs,
vector<int> node_types) {
if (n == 3) {
return sub1(
n, m, maxDiv2, target,
edge_froms, edge_tos, edge_costs, node_types);
}
return 0.0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
13 ms |
392 KB |
Wrong Answer. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
13 ms |
340 KB |
Wrong Answer. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
15 ms |
356 KB |
Wrong Answer. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
22 ms |
2124 KB |
Wrong Answer. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
17 ms |
340 KB |
Wrong Answer. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
24 ms |
340 KB |
Wrong Answer. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
17 ms |
384 KB |
Wrong Answer. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
15 ms |
388 KB |
Wrong Answer. |
2 |
Halted |
0 ms |
0 KB |
- |