#include <bits/stdc++.h>
#include"dreaming.h"
using namespace std;
#define pb push_back
#define fi first
#define se second
#define ll long long
const int MAX=1e5+10, MAXV=1e9+10;
int n, m, l, odl[MAX][2];
vector<pair<int,int>>g[MAX];
pair<int,int>maxi;
bool odw[MAX];
void dfso(int v, int oj, int x, int nr){
odl[v][nr]=x;
odw[v]=true;
maxi=max(maxi, {x, v});
for(auto s: g[v])
if(s.fi!=oj)
dfso(s.fi, v, x+s.se, nr);
}
pair<int,int>mini;
void dfs(int v, int oj){
mini=min(mini, {max(odl[v][0], odl[v][1]), v});
for(auto s: g[v])
if(s.fi!=oj)
dfs(s.fi,v);
}
int travelTime(int N, int M, int L, int a[], int b[], int t[]){
n=N, m=M, l=L;
for(int i=0; i<m; i++)
g[a[i]].pb({b[i], t[i]}), g[b[i]].pb({a[i], t[i]});
vector<int>v;
int maxiSr=0;
for(int i=0; i<n; i++){
if(odw[i])
continue;
maxi={0,0};
dfso(i, i, 0, 0);
int s1=maxi.se;
maxi={0,0};
dfso(s1, s1, 0, 0);
int s2=maxi.se;
maxi={0,0};
dfso(s2, s2, 0, 1);
maxiSr=max(maxiSr, maxi.fi);
mini={MAXV,0};
dfs(i, i);
int mid=mini.se;
v.pb(max(odl[mid][0], odl[mid][1]));
}
sort(v.begin(),v.end());
reverse(v.begin(),v.end());
if(v.size()>=2)
maxiSr=max(maxiSr, v[0]+v[1]+l);
return maxiSr;
}
/*int main(){
ios_base::sync_with_stdio(false);
cin.tie(0), cout.tie(0);
int N, M, L;
cin>>N>>M>>L;
int A[M+2], B[M+2], T[M+2];
for(int i=0; i<M; i++)
cin>>A[i]>>B[i]>>T[i];
cout<<travelTime(N, M, L, A, B, T)<<"\n";
}*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
50 ms |
14276 KB |
Output is correct |
2 |
Correct |
51 ms |
14276 KB |
Output is correct |
3 |
Correct |
31 ms |
10320 KB |
Output is correct |
4 |
Correct |
8 ms |
4308 KB |
Output is correct |
5 |
Correct |
7 ms |
3532 KB |
Output is correct |
6 |
Correct |
14 ms |
5204 KB |
Output is correct |
7 |
Correct |
2 ms |
2636 KB |
Output is correct |
8 |
Correct |
25 ms |
6724 KB |
Output is correct |
9 |
Correct |
30 ms |
8424 KB |
Output is correct |
10 |
Correct |
2 ms |
2636 KB |
Output is correct |
11 |
Correct |
43 ms |
10392 KB |
Output is correct |
12 |
Correct |
62 ms |
12100 KB |
Output is correct |
13 |
Correct |
2 ms |
2636 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
2636 KB |
Output is correct |
2 |
Correct |
2 ms |
2660 KB |
Output is correct |
3 |
Correct |
2 ms |
2636 KB |
Output is correct |
4 |
Correct |
2 ms |
2636 KB |
Output is correct |
5 |
Correct |
2 ms |
2656 KB |
Output is correct |
6 |
Correct |
2 ms |
2636 KB |
Output is correct |
7 |
Correct |
2 ms |
2648 KB |
Output is correct |
8 |
Correct |
1 ms |
2636 KB |
Output is correct |
9 |
Correct |
2 ms |
2636 KB |
Output is correct |
10 |
Correct |
2 ms |
2636 KB |
Output is correct |
11 |
Correct |
2 ms |
2652 KB |
Output is correct |
12 |
Correct |
3 ms |
2636 KB |
Output is correct |
13 |
Correct |
2 ms |
2636 KB |
Output is correct |
14 |
Correct |
2 ms |
2636 KB |
Output is correct |
15 |
Correct |
1 ms |
2636 KB |
Output is correct |
16 |
Correct |
2 ms |
2636 KB |
Output is correct |
17 |
Correct |
2 ms |
2656 KB |
Output is correct |
18 |
Correct |
2 ms |
2652 KB |
Output is correct |
19 |
Correct |
2 ms |
2660 KB |
Output is correct |
20 |
Correct |
2 ms |
2648 KB |
Output is correct |
21 |
Correct |
2 ms |
2636 KB |
Output is correct |
22 |
Correct |
2 ms |
2656 KB |
Output is correct |
23 |
Correct |
2 ms |
2636 KB |
Output is correct |
24 |
Correct |
2 ms |
2636 KB |
Output is correct |
25 |
Correct |
2 ms |
2636 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
50 ms |
14276 KB |
Output is correct |
2 |
Correct |
51 ms |
14276 KB |
Output is correct |
3 |
Correct |
31 ms |
10320 KB |
Output is correct |
4 |
Correct |
8 ms |
4308 KB |
Output is correct |
5 |
Correct |
7 ms |
3532 KB |
Output is correct |
6 |
Correct |
14 ms |
5204 KB |
Output is correct |
7 |
Correct |
2 ms |
2636 KB |
Output is correct |
8 |
Correct |
25 ms |
6724 KB |
Output is correct |
9 |
Correct |
30 ms |
8424 KB |
Output is correct |
10 |
Correct |
2 ms |
2636 KB |
Output is correct |
11 |
Correct |
43 ms |
10392 KB |
Output is correct |
12 |
Correct |
62 ms |
12100 KB |
Output is correct |
13 |
Correct |
2 ms |
2636 KB |
Output is correct |
14 |
Correct |
2 ms |
2636 KB |
Output is correct |
15 |
Correct |
2 ms |
2660 KB |
Output is correct |
16 |
Correct |
2 ms |
2636 KB |
Output is correct |
17 |
Correct |
2 ms |
2636 KB |
Output is correct |
18 |
Correct |
2 ms |
2656 KB |
Output is correct |
19 |
Correct |
2 ms |
2636 KB |
Output is correct |
20 |
Correct |
2 ms |
2648 KB |
Output is correct |
21 |
Correct |
1 ms |
2636 KB |
Output is correct |
22 |
Correct |
2 ms |
2636 KB |
Output is correct |
23 |
Correct |
2 ms |
2636 KB |
Output is correct |
24 |
Correct |
2 ms |
2652 KB |
Output is correct |
25 |
Correct |
3 ms |
2636 KB |
Output is correct |
26 |
Correct |
2 ms |
2636 KB |
Output is correct |
27 |
Correct |
2 ms |
2636 KB |
Output is correct |
28 |
Correct |
1 ms |
2636 KB |
Output is correct |
29 |
Correct |
2 ms |
2636 KB |
Output is correct |
30 |
Correct |
2 ms |
2656 KB |
Output is correct |
31 |
Correct |
2 ms |
2652 KB |
Output is correct |
32 |
Correct |
2 ms |
2660 KB |
Output is correct |
33 |
Correct |
2 ms |
2648 KB |
Output is correct |
34 |
Correct |
2 ms |
2636 KB |
Output is correct |
35 |
Correct |
2 ms |
2656 KB |
Output is correct |
36 |
Correct |
2 ms |
2636 KB |
Output is correct |
37 |
Correct |
2 ms |
2636 KB |
Output is correct |
38 |
Correct |
2 ms |
2636 KB |
Output is correct |
39 |
Correct |
49 ms |
14312 KB |
Output is correct |
40 |
Correct |
47 ms |
14236 KB |
Output is correct |
41 |
Correct |
29 ms |
10436 KB |
Output is correct |
42 |
Correct |
7 ms |
4316 KB |
Output is correct |
43 |
Correct |
2 ms |
2636 KB |
Output is correct |
44 |
Correct |
2 ms |
2636 KB |
Output is correct |
45 |
Correct |
2 ms |
2636 KB |
Output is correct |
46 |
Correct |
2 ms |
2636 KB |
Output is correct |
47 |
Correct |
2 ms |
2636 KB |
Output is correct |
48 |
Correct |
2 ms |
2636 KB |
Output is correct |
49 |
Correct |
2 ms |
2636 KB |
Output is correct |
50 |
Correct |
2 ms |
2636 KB |
Output is correct |
51 |
Correct |
2 ms |
2636 KB |
Output is correct |
52 |
Correct |
2 ms |
2636 KB |
Output is correct |
53 |
Correct |
3 ms |
2636 KB |
Output is correct |
54 |
Correct |
2 ms |
2636 KB |
Output is correct |
55 |
Correct |
2 ms |
2636 KB |
Output is correct |
56 |
Correct |
1 ms |
2636 KB |
Output is correct |
57 |
Correct |
69 ms |
9928 KB |
Output is correct |
58 |
Correct |
61 ms |
9916 KB |
Output is correct |
59 |
Correct |
62 ms |
9860 KB |
Output is correct |
60 |
Correct |
62 ms |
9852 KB |
Output is correct |
61 |
Correct |
60 ms |
10048 KB |
Output is correct |
62 |
Correct |
59 ms |
9924 KB |
Output is correct |
63 |
Correct |
58 ms |
9708 KB |
Output is correct |
64 |
Correct |
56 ms |
9600 KB |
Output is correct |
65 |
Correct |
62 ms |
10084 KB |
Output is correct |
66 |
Correct |
60 ms |
9924 KB |
Output is correct |
67 |
Correct |
62 ms |
9944 KB |
Output is correct |
68 |
Correct |
63 ms |
9924 KB |
Output is correct |
69 |
Correct |
64 ms |
10216 KB |
Output is correct |
70 |
Correct |
77 ms |
10308 KB |
Output is correct |
71 |
Correct |
2 ms |
2764 KB |
Output is correct |
72 |
Correct |
3 ms |
2764 KB |
Output is correct |
73 |
Correct |
3 ms |
2764 KB |
Output is correct |
74 |
Correct |
3 ms |
2764 KB |
Output is correct |
75 |
Correct |
3 ms |
2764 KB |
Output is correct |
76 |
Correct |
3 ms |
2796 KB |
Output is correct |
77 |
Correct |
3 ms |
2764 KB |
Output is correct |
78 |
Correct |
3 ms |
2892 KB |
Output is correct |
79 |
Correct |
2 ms |
2892 KB |
Output is correct |
80 |
Correct |
67 ms |
9928 KB |
Output is correct |
81 |
Correct |
73 ms |
9924 KB |
Output is correct |
82 |
Correct |
61 ms |
10004 KB |
Output is correct |
83 |
Correct |
69 ms |
9988 KB |
Output is correct |
84 |
Correct |
2 ms |
2764 KB |
Output is correct |
85 |
Correct |
2 ms |
2796 KB |
Output is correct |
86 |
Correct |
3 ms |
2796 KB |
Output is correct |
87 |
Correct |
3 ms |
2764 KB |
Output is correct |
88 |
Correct |
2 ms |
2764 KB |
Output is correct |
89 |
Correct |
3 ms |
2796 KB |
Output is correct |
90 |
Correct |
3 ms |
2848 KB |
Output is correct |
91 |
Correct |
3 ms |
2840 KB |
Output is correct |
92 |
Correct |
3 ms |
2836 KB |
Output is correct |
93 |
Correct |
3 ms |
2764 KB |
Output is correct |
94 |
Correct |
2 ms |
2636 KB |
Output is correct |
95 |
Correct |
2 ms |
2764 KB |
Output is correct |
96 |
Correct |
2 ms |
2636 KB |
Output is correct |
97 |
Correct |
2 ms |
2636 KB |
Output is correct |
98 |
Correct |
2 ms |
2652 KB |
Output is correct |
99 |
Correct |
2 ms |
2652 KB |
Output is correct |
100 |
Correct |
2 ms |
2636 KB |
Output is correct |
101 |
Correct |
2 ms |
2636 KB |
Output is correct |
102 |
Correct |
2 ms |
2652 KB |
Output is correct |
103 |
Correct |
2 ms |
2636 KB |
Output is correct |
104 |
Correct |
6 ms |
3532 KB |
Output is correct |
105 |
Correct |
12 ms |
5220 KB |
Output is correct |
106 |
Correct |
2 ms |
2660 KB |
Output is correct |
107 |
Correct |
22 ms |
6688 KB |
Output is correct |
108 |
Correct |
32 ms |
8388 KB |
Output is correct |
109 |
Correct |
2 ms |
2636 KB |
Output is correct |
110 |
Correct |
47 ms |
10388 KB |
Output is correct |
111 |
Correct |
57 ms |
12160 KB |
Output is correct |
112 |
Correct |
2 ms |
2636 KB |
Output is correct |
113 |
Correct |
81 ms |
15588 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
20 ms |
6596 KB |
Output is correct |
2 |
Incorrect |
21 ms |
6608 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
2636 KB |
Output is correct |
2 |
Correct |
2 ms |
2660 KB |
Output is correct |
3 |
Correct |
2 ms |
2636 KB |
Output is correct |
4 |
Correct |
2 ms |
2636 KB |
Output is correct |
5 |
Correct |
2 ms |
2656 KB |
Output is correct |
6 |
Correct |
2 ms |
2636 KB |
Output is correct |
7 |
Correct |
2 ms |
2648 KB |
Output is correct |
8 |
Correct |
1 ms |
2636 KB |
Output is correct |
9 |
Correct |
2 ms |
2636 KB |
Output is correct |
10 |
Correct |
2 ms |
2636 KB |
Output is correct |
11 |
Correct |
2 ms |
2652 KB |
Output is correct |
12 |
Correct |
3 ms |
2636 KB |
Output is correct |
13 |
Correct |
2 ms |
2636 KB |
Output is correct |
14 |
Correct |
2 ms |
2636 KB |
Output is correct |
15 |
Correct |
1 ms |
2636 KB |
Output is correct |
16 |
Correct |
2 ms |
2636 KB |
Output is correct |
17 |
Correct |
2 ms |
2656 KB |
Output is correct |
18 |
Correct |
2 ms |
2652 KB |
Output is correct |
19 |
Correct |
2 ms |
2660 KB |
Output is correct |
20 |
Correct |
2 ms |
2648 KB |
Output is correct |
21 |
Correct |
2 ms |
2636 KB |
Output is correct |
22 |
Correct |
2 ms |
2656 KB |
Output is correct |
23 |
Correct |
2 ms |
2636 KB |
Output is correct |
24 |
Correct |
2 ms |
2636 KB |
Output is correct |
25 |
Correct |
2 ms |
2636 KB |
Output is correct |
26 |
Correct |
2 ms |
2636 KB |
Output is correct |
27 |
Correct |
2 ms |
2668 KB |
Output is correct |
28 |
Correct |
4 ms |
2892 KB |
Output is correct |
29 |
Correct |
2 ms |
2636 KB |
Output is correct |
30 |
Correct |
2 ms |
2764 KB |
Output is correct |
31 |
Correct |
3 ms |
2800 KB |
Output is correct |
32 |
Incorrect |
2 ms |
2636 KB |
Output isn't correct |
33 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
50 ms |
14276 KB |
Output is correct |
2 |
Correct |
51 ms |
14276 KB |
Output is correct |
3 |
Correct |
31 ms |
10320 KB |
Output is correct |
4 |
Correct |
8 ms |
4308 KB |
Output is correct |
5 |
Correct |
7 ms |
3532 KB |
Output is correct |
6 |
Correct |
14 ms |
5204 KB |
Output is correct |
7 |
Correct |
2 ms |
2636 KB |
Output is correct |
8 |
Correct |
25 ms |
6724 KB |
Output is correct |
9 |
Correct |
30 ms |
8424 KB |
Output is correct |
10 |
Correct |
2 ms |
2636 KB |
Output is correct |
11 |
Correct |
43 ms |
10392 KB |
Output is correct |
12 |
Correct |
62 ms |
12100 KB |
Output is correct |
13 |
Correct |
2 ms |
2636 KB |
Output is correct |
14 |
Correct |
2 ms |
2636 KB |
Output is correct |
15 |
Correct |
2 ms |
2660 KB |
Output is correct |
16 |
Correct |
2 ms |
2636 KB |
Output is correct |
17 |
Correct |
2 ms |
2636 KB |
Output is correct |
18 |
Correct |
2 ms |
2656 KB |
Output is correct |
19 |
Correct |
2 ms |
2636 KB |
Output is correct |
20 |
Correct |
2 ms |
2648 KB |
Output is correct |
21 |
Correct |
1 ms |
2636 KB |
Output is correct |
22 |
Correct |
2 ms |
2636 KB |
Output is correct |
23 |
Correct |
2 ms |
2636 KB |
Output is correct |
24 |
Correct |
2 ms |
2652 KB |
Output is correct |
25 |
Correct |
3 ms |
2636 KB |
Output is correct |
26 |
Correct |
2 ms |
2636 KB |
Output is correct |
27 |
Correct |
2 ms |
2636 KB |
Output is correct |
28 |
Correct |
1 ms |
2636 KB |
Output is correct |
29 |
Correct |
2 ms |
2636 KB |
Output is correct |
30 |
Correct |
2 ms |
2656 KB |
Output is correct |
31 |
Correct |
2 ms |
2652 KB |
Output is correct |
32 |
Correct |
2 ms |
2660 KB |
Output is correct |
33 |
Correct |
2 ms |
2648 KB |
Output is correct |
34 |
Correct |
2 ms |
2636 KB |
Output is correct |
35 |
Correct |
2 ms |
2656 KB |
Output is correct |
36 |
Correct |
2 ms |
2636 KB |
Output is correct |
37 |
Correct |
2 ms |
2636 KB |
Output is correct |
38 |
Correct |
2 ms |
2636 KB |
Output is correct |
39 |
Correct |
49 ms |
14312 KB |
Output is correct |
40 |
Correct |
47 ms |
14236 KB |
Output is correct |
41 |
Correct |
29 ms |
10436 KB |
Output is correct |
42 |
Correct |
7 ms |
4316 KB |
Output is correct |
43 |
Correct |
2 ms |
2636 KB |
Output is correct |
44 |
Correct |
2 ms |
2636 KB |
Output is correct |
45 |
Correct |
2 ms |
2636 KB |
Output is correct |
46 |
Correct |
2 ms |
2636 KB |
Output is correct |
47 |
Correct |
2 ms |
2636 KB |
Output is correct |
48 |
Correct |
2 ms |
2636 KB |
Output is correct |
49 |
Correct |
2 ms |
2636 KB |
Output is correct |
50 |
Correct |
2 ms |
2636 KB |
Output is correct |
51 |
Correct |
2 ms |
2636 KB |
Output is correct |
52 |
Correct |
2 ms |
2636 KB |
Output is correct |
53 |
Correct |
3 ms |
2636 KB |
Output is correct |
54 |
Correct |
2 ms |
2636 KB |
Output is correct |
55 |
Correct |
2 ms |
2636 KB |
Output is correct |
56 |
Correct |
1 ms |
2636 KB |
Output is correct |
57 |
Correct |
69 ms |
9928 KB |
Output is correct |
58 |
Correct |
61 ms |
9916 KB |
Output is correct |
59 |
Correct |
62 ms |
9860 KB |
Output is correct |
60 |
Correct |
62 ms |
9852 KB |
Output is correct |
61 |
Correct |
60 ms |
10048 KB |
Output is correct |
62 |
Correct |
59 ms |
9924 KB |
Output is correct |
63 |
Correct |
58 ms |
9708 KB |
Output is correct |
64 |
Correct |
56 ms |
9600 KB |
Output is correct |
65 |
Correct |
62 ms |
10084 KB |
Output is correct |
66 |
Correct |
60 ms |
9924 KB |
Output is correct |
67 |
Correct |
62 ms |
9944 KB |
Output is correct |
68 |
Correct |
63 ms |
9924 KB |
Output is correct |
69 |
Correct |
64 ms |
10216 KB |
Output is correct |
70 |
Correct |
77 ms |
10308 KB |
Output is correct |
71 |
Correct |
2 ms |
2764 KB |
Output is correct |
72 |
Correct |
3 ms |
2764 KB |
Output is correct |
73 |
Correct |
3 ms |
2764 KB |
Output is correct |
74 |
Correct |
3 ms |
2764 KB |
Output is correct |
75 |
Correct |
3 ms |
2764 KB |
Output is correct |
76 |
Correct |
3 ms |
2796 KB |
Output is correct |
77 |
Correct |
3 ms |
2764 KB |
Output is correct |
78 |
Correct |
3 ms |
2892 KB |
Output is correct |
79 |
Correct |
2 ms |
2892 KB |
Output is correct |
80 |
Correct |
67 ms |
9928 KB |
Output is correct |
81 |
Correct |
73 ms |
9924 KB |
Output is correct |
82 |
Correct |
61 ms |
10004 KB |
Output is correct |
83 |
Correct |
69 ms |
9988 KB |
Output is correct |
84 |
Correct |
2 ms |
2764 KB |
Output is correct |
85 |
Correct |
2 ms |
2796 KB |
Output is correct |
86 |
Correct |
3 ms |
2796 KB |
Output is correct |
87 |
Correct |
3 ms |
2764 KB |
Output is correct |
88 |
Correct |
2 ms |
2764 KB |
Output is correct |
89 |
Correct |
3 ms |
2796 KB |
Output is correct |
90 |
Correct |
3 ms |
2848 KB |
Output is correct |
91 |
Correct |
3 ms |
2840 KB |
Output is correct |
92 |
Correct |
3 ms |
2836 KB |
Output is correct |
93 |
Correct |
3 ms |
2764 KB |
Output is correct |
94 |
Correct |
2 ms |
2636 KB |
Output is correct |
95 |
Correct |
2 ms |
2764 KB |
Output is correct |
96 |
Correct |
2 ms |
2636 KB |
Output is correct |
97 |
Correct |
2 ms |
2636 KB |
Output is correct |
98 |
Correct |
2 ms |
2652 KB |
Output is correct |
99 |
Correct |
2 ms |
2652 KB |
Output is correct |
100 |
Correct |
2 ms |
2636 KB |
Output is correct |
101 |
Correct |
2 ms |
2636 KB |
Output is correct |
102 |
Correct |
2 ms |
2652 KB |
Output is correct |
103 |
Correct |
2 ms |
2636 KB |
Output is correct |
104 |
Correct |
6 ms |
3532 KB |
Output is correct |
105 |
Correct |
12 ms |
5220 KB |
Output is correct |
106 |
Correct |
2 ms |
2660 KB |
Output is correct |
107 |
Correct |
22 ms |
6688 KB |
Output is correct |
108 |
Correct |
32 ms |
8388 KB |
Output is correct |
109 |
Correct |
2 ms |
2636 KB |
Output is correct |
110 |
Correct |
47 ms |
10388 KB |
Output is correct |
111 |
Correct |
57 ms |
12160 KB |
Output is correct |
112 |
Correct |
2 ms |
2636 KB |
Output is correct |
113 |
Correct |
81 ms |
15588 KB |
Output is correct |
114 |
Correct |
20 ms |
6596 KB |
Output is correct |
115 |
Incorrect |
21 ms |
6608 KB |
Output isn't correct |
116 |
Halted |
0 ms |
0 KB |
- |