#include "dreaming.h"
#include <bits/stdc++.h>
using namespace std;
int travelTime(int n, int m, int l, int a[], int b[], int t[]){
vector<pair<int,int>>vct[n];
for(int i=0;i<m;i++){
vct[a[i]].push_back({b[i],t[i]});
vct[b[i]].push_back({a[i],t[i]});
}
deque<int>v;
vector<int>vis(n);
for(int i=0;i<n;i++){
if(vis[i])continue;
vis[i]=1;
vector<int>vc={i};
{
deque<int>dq={i};
while(dq.size()){
int a=dq.front();
dq.pop_front();
for(auto &w:vct[a]){
if(!vis[w.first]){
vis[w.first]=1;
dq.push_back(w.first);
vc.push_back(w.first);
}
}
}
}
int f=INT_MAX;
for(auto &w:vc){
vector<bool>vv(n);
deque<pair<int,int>>dq={{w,0}};
vv[w]=1;
int g=0;
while(dq.size()){
int a=dq.front().first,b=dq.front().second;
dq.pop_front();
g=max(g,b);
for(auto &j:vct[a]){
if(!vv[j.first]){
vv[j.first]=1;
dq.push_back({j.first,j.second+b});
}
}
}
f=min(f,g);
}
v.push_back(f);
}
while(v.size()>1){
sort(v.begin(),v.end());
v[1]=max(v[1],v[0]+l);
v.pop_front();
}
return v.back();
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1087 ms |
8524 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1087 ms |
8524 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1077 ms |
5884 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1087 ms |
8524 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |