#define _GLIBCXX_DEBUG
#include "dreaming.h"
#include<bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define pb push_back
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vvi = vector<vi>;
using pi = pair<ll, ll>;
using vpi = vector<pi>;
using vvpi = vector<vpi>;
int n;
vvpi g;
vi diams, comp;
bitset<5000> vis;
void dc(int v) {
comp.pb(v);
vis.set(v);
for(auto i : g[v])
if(!vis.test(i.first)) dc(i.first);
}
ll dfs(int v, int p) {
ll x=0;
for(auto i : g[v])
if(i.first!=p) x = max(x, i.second+dfs(i.first, v));
return x;
}
int travelTime(int N, int M, int L, int A[], int B[], int T[]) {
n = N;
g.resize(n);
ll ans = 0;
// cout << N << " " << M << "\n";
return 0;
for(int f, t, c, i = 0; i < M; i++) {
f = A[i], t = A[i], c = T[i];
// cout <<f << " " << t << "\n";
g[f].pb({t, c});
g[t].pb({f, c});
}
for(int i = 0; i < n; i++) {
if(!vis[i]) {
comp.clear();
dc(i);
ll d = 0;
for(auto j : comp)
d = max(d, dfs(j, j));
diams.pb(d);
}
}
sort(all(diams));
if(diams.size()==1)ans=diams[0];
else ans = diams[0]+L+diams[1];
if(diams.size()>2) ans = max(ans, diams[2]+L+L+diams[1]);
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
39 ms |
7800 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
39 ms |
7800 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
39 ms |
7800 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
18 ms |
6264 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
39 ms |
7800 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
39 ms |
7800 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |