#include "dreaming.h"
#include<bits/stdc++.h>
using namespace std;
int d[3][1<<17],f[1<<17],W[1<<17],w,e,D,X=-1,Y=-1,Z=-1;
vector<pair<int,int> >v[1<<17];
void U(int x,int o){
f[x]++;
if(o<2&&d[o][x]>=D)e=x,D=d[o][x];
if(o>1)D=min(D,max(d[1][x],d[2][x]));
for(auto y:v[x])if(f[y.first]<=o)d[o][y.first]=d[o][x]+y.second,U(y.first,o);
}
int travelTime(int N,int M,int L,int A[],int B[],int T[]){
while(M--)v[A[M]].push_back({B[M],T[M]}),v[B[M]].push_back({A[M],T[M]});
while(N--)if(!f[N])U(N,0),U(e,1),U(e,2),W[w++]=D,D=0;
while(w--){
if(Z<W[w])Z=W[w];
if(Y<W[w])Z=Y,Y=W[w];
if(X<W[w])Y=X,X=W[w];
}
return max(X,Z+(Z>=0)*L)+Y+(Y>=0)*L;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
59 ms |
15852 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
3436 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
59 ms |
15852 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
29 ms |
7472 KB |
Output is correct |
2 |
Correct |
33 ms |
7572 KB |
Output is correct |
3 |
Correct |
26 ms |
7532 KB |
Output is correct |
4 |
Correct |
26 ms |
7532 KB |
Output is correct |
5 |
Correct |
28 ms |
7660 KB |
Output is correct |
6 |
Correct |
29 ms |
7788 KB |
Output is correct |
7 |
Correct |
29 ms |
7788 KB |
Output is correct |
8 |
Correct |
27 ms |
7532 KB |
Output is correct |
9 |
Correct |
33 ms |
7404 KB |
Output is correct |
10 |
Correct |
35 ms |
7660 KB |
Output is correct |
11 |
Correct |
3 ms |
3436 KB |
Output is correct |
12 |
Correct |
6 ms |
5228 KB |
Output is correct |
13 |
Correct |
6 ms |
5356 KB |
Output is correct |
14 |
Correct |
6 ms |
5228 KB |
Output is correct |
15 |
Correct |
7 ms |
5228 KB |
Output is correct |
16 |
Correct |
6 ms |
5100 KB |
Output is correct |
17 |
Correct |
6 ms |
4588 KB |
Output is correct |
18 |
Correct |
6 ms |
5356 KB |
Output is correct |
19 |
Correct |
7 ms |
5100 KB |
Output is correct |
20 |
Incorrect |
3 ms |
3436 KB |
Output isn't correct |
21 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
3436 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
59 ms |
15852 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |