#include "dreaming.h"
#include <bits/stdc++.h>
using namespace std;
const int NN = 3003;
int a[NN], b[NN], t[NN];
vector<pair<int, int>> g[NN];
int vis[NN];
int far[NN];
int travelTime(int N, int M, int L, int A[], int B[], int T[]) {
int n, m, l;
n = N, m = M, l = L;
for (int i = 0; i < m; ++i) {
a[i] = A[i];
b[i] = B[i];
t[i] = T[i];
}
for (int i = 0; i < m; ++i) {
g[a[i]].emplace_back(b[i], t[i]);
g[b[i]].emplace_back(a[i], t[i]);
}
int ncc = 0;
function<void(int, int)> pre = [&](int v, int p) {
vis[v] = ncc;
for (auto it : g[v]) {
int u = it.first;
if (!vis[u]) {
pre(u, v);
}
}
};
for (int i = 0; i < n; ++i) {
if (!vis[i]) {
ncc++;
pre(i, i);
}
}
function<void(int, int, int, int)> Dfs = [&](int v, int p, int rt, int mx) {
far[v] = max(far[v], mx);
for (auto it : g[v]) {
int u = it.first;
int w = it.second;
if (u != p) {
Dfs(u, v, rt, mx + w);
}
}
};
for (int i = 0; i < n; ++i) {
Dfs(i, i, i, 0);
}
vector<int> fc(ncc + 1, 1e9);
for (int i = 0; i < n; ++i) {
fc[vis[i]] = min(fc[vis[i]], far[i]);
}
int ans = fc[1] + fc[2] + l;
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
23 ms |
3028 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
23 ms |
3028 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
13 ms |
1584 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
23 ms |
3028 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |