# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
206929 |
2020-03-06T00:10:31 Z |
oko |
Dreaming (IOI13_dreaming) |
C++14 |
|
206 ms |
36472 KB |
#include<bits/stdc++.h>
#include "dreaming.h"
using namespace std;
const long long mod=1e9+7;
long long n,m,l,st1,st2,vis[100005],mn=1e10,dis[100005],mx;
vector<pair<int,int> >gr[100005];
void dfs(int x)
{
vis[x]=1;
for(int i=0;i<gr[x].size();i++)
{
int u=gr[x][i].first;
if(vis[u])continue;
dfs(u);
}
}
void cal(int x)
{
vis[x]=1;
for(int i=0;i<gr[x].size();i++)
{
int u=gr[x][i].first,w=gr[x][i].second;
if(vis[u])continue;
cal(u);
dis[x]=max(dis[x],dis[u]+w);
}
}
void root(int x)
{
vis[x]=1;
mn=min(mn,dis[x]);
mx=max(mx,dis[x]);
multiset<int>ms;
ms.insert(0);
for(int i=0;i<gr[x].size();i++)
{
int u=gr[x][i].first,w=gr[x][i].second;
ms.insert(dis[u]+w);
}
for(int i=0;i<gr[x].size();i++)
{
int u=gr[x][i].first,w=gr[x][i].second;
if(vis[u])continue;
ms.erase(ms.lower_bound(dis[u]+w));
long long oldx=dis[x],oldu=dis[u];
dis[x]=*--ms.end();
dis[u]=max(dis[u],dis[x]+w);
root(u);
dis[x]=oldx;
dis[u]=oldu;
ms.insert(dis[u]+w);
}
}
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++)
{
gr[A[i]+1].push_back({B[i]+1,T[i]});
gr[B[i]+1].push_back({A[i]+1,T[i]});
}
for(int i=1;i<=n;i++)
{
if(vis[i]==0&&st1==0)
{
dfs(i);
st1=i;
}
if(vis[i]==0&&st1)
{
dfs(i);
st2=i;
}
}
memset(vis,0,sizeof vis);
cal(st1);
memset(vis,0,sizeof vis);
root(st1);
long long ans=mn;
mn=1e10;
memset(vis,0,sizeof vis);
cal(st2);
memset(vis,0,sizeof vis);
root(st2);
return max(mx,ans+mn+l);
}
Compilation message
dreaming.cpp: In function 'void dfs(int)':
dreaming.cpp:12:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i=0;i<gr[x].size();i++)
~^~~~~~~~~~~~~
dreaming.cpp: In function 'void cal(int)':
dreaming.cpp:22:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i=0;i<gr[x].size();i++)
~^~~~~~~~~~~~~
dreaming.cpp: In function 'void root(int)':
dreaming.cpp:37:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i=0;i<gr[x].size();i++)
~^~~~~~~~~~~~~
dreaming.cpp:42:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i=0;i<gr[x].size();i++)
~^~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
103 ms |
21496 KB |
Output is correct |
2 |
Correct |
99 ms |
21752 KB |
Output is correct |
3 |
Correct |
67 ms |
21112 KB |
Output is correct |
4 |
Correct |
18 ms |
6392 KB |
Output is correct |
5 |
Correct |
15 ms |
4856 KB |
Output is correct |
6 |
Correct |
26 ms |
7704 KB |
Output is correct |
7 |
Correct |
7 ms |
3492 KB |
Output is correct |
8 |
Correct |
50 ms |
11384 KB |
Output is correct |
9 |
Correct |
67 ms |
17016 KB |
Output is correct |
10 |
Correct |
7 ms |
3580 KB |
Output is correct |
11 |
Correct |
103 ms |
17016 KB |
Output is correct |
12 |
Correct |
120 ms |
19832 KB |
Output is correct |
13 |
Correct |
8 ms |
3608 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
103 ms |
21496 KB |
Output is correct |
2 |
Correct |
99 ms |
21752 KB |
Output is correct |
3 |
Correct |
67 ms |
21112 KB |
Output is correct |
4 |
Correct |
18 ms |
6392 KB |
Output is correct |
5 |
Correct |
15 ms |
4856 KB |
Output is correct |
6 |
Correct |
26 ms |
7704 KB |
Output is correct |
7 |
Correct |
7 ms |
3492 KB |
Output is correct |
8 |
Correct |
50 ms |
11384 KB |
Output is correct |
9 |
Correct |
67 ms |
17016 KB |
Output is correct |
10 |
Correct |
7 ms |
3580 KB |
Output is correct |
11 |
Correct |
103 ms |
17016 KB |
Output is correct |
12 |
Correct |
120 ms |
19832 KB |
Output is correct |
13 |
Correct |
8 ms |
3608 KB |
Output is correct |
14 |
Correct |
6 ms |
3448 KB |
Output is correct |
15 |
Correct |
7 ms |
3448 KB |
Output is correct |
16 |
Correct |
7 ms |
3448 KB |
Output is correct |
17 |
Correct |
6 ms |
3448 KB |
Output is correct |
18 |
Correct |
7 ms |
3448 KB |
Output is correct |
19 |
Correct |
8 ms |
3448 KB |
Output is correct |
20 |
Correct |
7 ms |
3448 KB |
Output is correct |
21 |
Correct |
7 ms |
3448 KB |
Output is correct |
22 |
Correct |
7 ms |
3448 KB |
Output is correct |
23 |
Correct |
7 ms |
3448 KB |
Output is correct |
24 |
Correct |
6 ms |
3452 KB |
Output is correct |
25 |
Correct |
7 ms |
3448 KB |
Output is correct |
26 |
Correct |
7 ms |
3448 KB |
Output is correct |
27 |
Correct |
7 ms |
3448 KB |
Output is correct |
28 |
Correct |
7 ms |
3452 KB |
Output is correct |
29 |
Correct |
7 ms |
3448 KB |
Output is correct |
30 |
Correct |
7 ms |
3448 KB |
Output is correct |
31 |
Correct |
7 ms |
3448 KB |
Output is correct |
32 |
Correct |
7 ms |
3448 KB |
Output is correct |
33 |
Correct |
6 ms |
3448 KB |
Output is correct |
34 |
Correct |
7 ms |
3452 KB |
Output is correct |
35 |
Correct |
7 ms |
3424 KB |
Output is correct |
36 |
Correct |
7 ms |
3448 KB |
Output is correct |
37 |
Correct |
7 ms |
3448 KB |
Output is correct |
38 |
Correct |
7 ms |
3448 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
103 ms |
21496 KB |
Output is correct |
2 |
Correct |
99 ms |
21752 KB |
Output is correct |
3 |
Correct |
67 ms |
21112 KB |
Output is correct |
4 |
Correct |
18 ms |
6392 KB |
Output is correct |
5 |
Correct |
15 ms |
4856 KB |
Output is correct |
6 |
Correct |
26 ms |
7704 KB |
Output is correct |
7 |
Correct |
7 ms |
3492 KB |
Output is correct |
8 |
Correct |
50 ms |
11384 KB |
Output is correct |
9 |
Correct |
67 ms |
17016 KB |
Output is correct |
10 |
Correct |
7 ms |
3580 KB |
Output is correct |
11 |
Correct |
103 ms |
17016 KB |
Output is correct |
12 |
Correct |
120 ms |
19832 KB |
Output is correct |
13 |
Correct |
8 ms |
3608 KB |
Output is correct |
14 |
Correct |
6 ms |
3448 KB |
Output is correct |
15 |
Correct |
7 ms |
3448 KB |
Output is correct |
16 |
Correct |
7 ms |
3448 KB |
Output is correct |
17 |
Correct |
6 ms |
3448 KB |
Output is correct |
18 |
Correct |
7 ms |
3448 KB |
Output is correct |
19 |
Correct |
8 ms |
3448 KB |
Output is correct |
20 |
Correct |
7 ms |
3448 KB |
Output is correct |
21 |
Correct |
7 ms |
3448 KB |
Output is correct |
22 |
Correct |
7 ms |
3448 KB |
Output is correct |
23 |
Correct |
7 ms |
3448 KB |
Output is correct |
24 |
Correct |
6 ms |
3452 KB |
Output is correct |
25 |
Correct |
7 ms |
3448 KB |
Output is correct |
26 |
Correct |
7 ms |
3448 KB |
Output is correct |
27 |
Correct |
7 ms |
3448 KB |
Output is correct |
28 |
Correct |
7 ms |
3452 KB |
Output is correct |
29 |
Correct |
7 ms |
3448 KB |
Output is correct |
30 |
Correct |
7 ms |
3448 KB |
Output is correct |
31 |
Correct |
7 ms |
3448 KB |
Output is correct |
32 |
Correct |
7 ms |
3448 KB |
Output is correct |
33 |
Correct |
6 ms |
3448 KB |
Output is correct |
34 |
Correct |
7 ms |
3452 KB |
Output is correct |
35 |
Correct |
7 ms |
3424 KB |
Output is correct |
36 |
Correct |
7 ms |
3448 KB |
Output is correct |
37 |
Correct |
7 ms |
3448 KB |
Output is correct |
38 |
Correct |
7 ms |
3448 KB |
Output is correct |
39 |
Correct |
104 ms |
22776 KB |
Output is correct |
40 |
Correct |
98 ms |
21752 KB |
Output is correct |
41 |
Correct |
68 ms |
21112 KB |
Output is correct |
42 |
Correct |
12 ms |
6264 KB |
Output is correct |
43 |
Correct |
7 ms |
3448 KB |
Output is correct |
44 |
Correct |
7 ms |
3448 KB |
Output is correct |
45 |
Correct |
8 ms |
3448 KB |
Output is correct |
46 |
Correct |
7 ms |
3448 KB |
Output is correct |
47 |
Correct |
7 ms |
3448 KB |
Output is correct |
48 |
Correct |
7 ms |
3448 KB |
Output is correct |
49 |
Correct |
6 ms |
3448 KB |
Output is correct |
50 |
Correct |
7 ms |
3448 KB |
Output is correct |
51 |
Correct |
7 ms |
3448 KB |
Output is correct |
52 |
Correct |
7 ms |
3448 KB |
Output is correct |
53 |
Correct |
6 ms |
3448 KB |
Output is correct |
54 |
Correct |
7 ms |
3448 KB |
Output is correct |
55 |
Correct |
7 ms |
3448 KB |
Output is correct |
56 |
Correct |
7 ms |
3448 KB |
Output is correct |
57 |
Correct |
124 ms |
10744 KB |
Output is correct |
58 |
Correct |
129 ms |
10916 KB |
Output is correct |
59 |
Correct |
132 ms |
11000 KB |
Output is correct |
60 |
Correct |
131 ms |
10872 KB |
Output is correct |
61 |
Correct |
129 ms |
11000 KB |
Output is correct |
62 |
Correct |
132 ms |
10968 KB |
Output is correct |
63 |
Correct |
132 ms |
10488 KB |
Output is correct |
64 |
Correct |
124 ms |
10616 KB |
Output is correct |
65 |
Correct |
130 ms |
10744 KB |
Output is correct |
66 |
Correct |
132 ms |
10872 KB |
Output is correct |
67 |
Correct |
125 ms |
11132 KB |
Output is correct |
68 |
Correct |
128 ms |
11004 KB |
Output is correct |
69 |
Correct |
165 ms |
11332 KB |
Output is correct |
70 |
Correct |
131 ms |
11256 KB |
Output is correct |
71 |
Correct |
6 ms |
3448 KB |
Output is correct |
72 |
Correct |
9 ms |
3704 KB |
Output is correct |
73 |
Correct |
9 ms |
3704 KB |
Output is correct |
74 |
Correct |
10 ms |
3704 KB |
Output is correct |
75 |
Correct |
9 ms |
3704 KB |
Output is correct |
76 |
Correct |
10 ms |
3704 KB |
Output is correct |
77 |
Correct |
9 ms |
3704 KB |
Output is correct |
78 |
Correct |
9 ms |
3704 KB |
Output is correct |
79 |
Correct |
9 ms |
3704 KB |
Output is correct |
80 |
Correct |
138 ms |
10872 KB |
Output is correct |
81 |
Correct |
138 ms |
10872 KB |
Output is correct |
82 |
Correct |
128 ms |
10872 KB |
Output is correct |
83 |
Correct |
137 ms |
10872 KB |
Output is correct |
84 |
Correct |
9 ms |
3708 KB |
Output is correct |
85 |
Correct |
8 ms |
3576 KB |
Output is correct |
86 |
Correct |
9 ms |
3704 KB |
Output is correct |
87 |
Correct |
9 ms |
3704 KB |
Output is correct |
88 |
Correct |
9 ms |
3704 KB |
Output is correct |
89 |
Correct |
9 ms |
3704 KB |
Output is correct |
90 |
Correct |
8 ms |
3704 KB |
Output is correct |
91 |
Correct |
9 ms |
3704 KB |
Output is correct |
92 |
Correct |
10 ms |
3704 KB |
Output is correct |
93 |
Correct |
9 ms |
3704 KB |
Output is correct |
94 |
Correct |
7 ms |
3448 KB |
Output is correct |
95 |
Correct |
7 ms |
3448 KB |
Output is correct |
96 |
Correct |
7 ms |
3448 KB |
Output is correct |
97 |
Correct |
7 ms |
3448 KB |
Output is correct |
98 |
Correct |
6 ms |
3448 KB |
Output is correct |
99 |
Correct |
7 ms |
3448 KB |
Output is correct |
100 |
Correct |
7 ms |
3448 KB |
Output is correct |
101 |
Correct |
6 ms |
3448 KB |
Output is correct |
102 |
Correct |
7 ms |
3448 KB |
Output is correct |
103 |
Correct |
7 ms |
3444 KB |
Output is correct |
104 |
Correct |
15 ms |
4856 KB |
Output is correct |
105 |
Correct |
27 ms |
7672 KB |
Output is correct |
106 |
Correct |
7 ms |
3448 KB |
Output is correct |
107 |
Correct |
50 ms |
11256 KB |
Output is correct |
108 |
Correct |
77 ms |
17016 KB |
Output is correct |
109 |
Correct |
7 ms |
3704 KB |
Output is correct |
110 |
Correct |
105 ms |
16924 KB |
Output is correct |
111 |
Correct |
131 ms |
19832 KB |
Output is correct |
112 |
Correct |
7 ms |
3704 KB |
Output is correct |
113 |
Correct |
206 ms |
36472 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
25 ms |
5752 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
103 ms |
21496 KB |
Output is correct |
2 |
Correct |
99 ms |
21752 KB |
Output is correct |
3 |
Correct |
67 ms |
21112 KB |
Output is correct |
4 |
Correct |
18 ms |
6392 KB |
Output is correct |
5 |
Correct |
15 ms |
4856 KB |
Output is correct |
6 |
Correct |
26 ms |
7704 KB |
Output is correct |
7 |
Correct |
7 ms |
3492 KB |
Output is correct |
8 |
Correct |
50 ms |
11384 KB |
Output is correct |
9 |
Correct |
67 ms |
17016 KB |
Output is correct |
10 |
Correct |
7 ms |
3580 KB |
Output is correct |
11 |
Correct |
103 ms |
17016 KB |
Output is correct |
12 |
Correct |
120 ms |
19832 KB |
Output is correct |
13 |
Correct |
8 ms |
3608 KB |
Output is correct |
14 |
Incorrect |
9 ms |
3576 KB |
Output isn't correct |
15 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
103 ms |
21496 KB |
Output is correct |
2 |
Correct |
99 ms |
21752 KB |
Output is correct |
3 |
Correct |
67 ms |
21112 KB |
Output is correct |
4 |
Correct |
18 ms |
6392 KB |
Output is correct |
5 |
Correct |
15 ms |
4856 KB |
Output is correct |
6 |
Correct |
26 ms |
7704 KB |
Output is correct |
7 |
Correct |
7 ms |
3492 KB |
Output is correct |
8 |
Correct |
50 ms |
11384 KB |
Output is correct |
9 |
Correct |
67 ms |
17016 KB |
Output is correct |
10 |
Correct |
7 ms |
3580 KB |
Output is correct |
11 |
Correct |
103 ms |
17016 KB |
Output is correct |
12 |
Correct |
120 ms |
19832 KB |
Output is correct |
13 |
Correct |
8 ms |
3608 KB |
Output is correct |
14 |
Correct |
6 ms |
3448 KB |
Output is correct |
15 |
Correct |
7 ms |
3448 KB |
Output is correct |
16 |
Correct |
7 ms |
3448 KB |
Output is correct |
17 |
Correct |
6 ms |
3448 KB |
Output is correct |
18 |
Correct |
7 ms |
3448 KB |
Output is correct |
19 |
Correct |
8 ms |
3448 KB |
Output is correct |
20 |
Correct |
7 ms |
3448 KB |
Output is correct |
21 |
Correct |
7 ms |
3448 KB |
Output is correct |
22 |
Correct |
7 ms |
3448 KB |
Output is correct |
23 |
Correct |
7 ms |
3448 KB |
Output is correct |
24 |
Correct |
6 ms |
3452 KB |
Output is correct |
25 |
Correct |
7 ms |
3448 KB |
Output is correct |
26 |
Correct |
7 ms |
3448 KB |
Output is correct |
27 |
Correct |
7 ms |
3448 KB |
Output is correct |
28 |
Correct |
7 ms |
3452 KB |
Output is correct |
29 |
Correct |
7 ms |
3448 KB |
Output is correct |
30 |
Correct |
7 ms |
3448 KB |
Output is correct |
31 |
Correct |
7 ms |
3448 KB |
Output is correct |
32 |
Correct |
7 ms |
3448 KB |
Output is correct |
33 |
Correct |
6 ms |
3448 KB |
Output is correct |
34 |
Correct |
7 ms |
3452 KB |
Output is correct |
35 |
Correct |
7 ms |
3424 KB |
Output is correct |
36 |
Correct |
7 ms |
3448 KB |
Output is correct |
37 |
Correct |
7 ms |
3448 KB |
Output is correct |
38 |
Correct |
7 ms |
3448 KB |
Output is correct |
39 |
Correct |
104 ms |
22776 KB |
Output is correct |
40 |
Correct |
98 ms |
21752 KB |
Output is correct |
41 |
Correct |
68 ms |
21112 KB |
Output is correct |
42 |
Correct |
12 ms |
6264 KB |
Output is correct |
43 |
Correct |
7 ms |
3448 KB |
Output is correct |
44 |
Correct |
7 ms |
3448 KB |
Output is correct |
45 |
Correct |
8 ms |
3448 KB |
Output is correct |
46 |
Correct |
7 ms |
3448 KB |
Output is correct |
47 |
Correct |
7 ms |
3448 KB |
Output is correct |
48 |
Correct |
7 ms |
3448 KB |
Output is correct |
49 |
Correct |
6 ms |
3448 KB |
Output is correct |
50 |
Correct |
7 ms |
3448 KB |
Output is correct |
51 |
Correct |
7 ms |
3448 KB |
Output is correct |
52 |
Correct |
7 ms |
3448 KB |
Output is correct |
53 |
Correct |
6 ms |
3448 KB |
Output is correct |
54 |
Correct |
7 ms |
3448 KB |
Output is correct |
55 |
Correct |
7 ms |
3448 KB |
Output is correct |
56 |
Correct |
7 ms |
3448 KB |
Output is correct |
57 |
Correct |
124 ms |
10744 KB |
Output is correct |
58 |
Correct |
129 ms |
10916 KB |
Output is correct |
59 |
Correct |
132 ms |
11000 KB |
Output is correct |
60 |
Correct |
131 ms |
10872 KB |
Output is correct |
61 |
Correct |
129 ms |
11000 KB |
Output is correct |
62 |
Correct |
132 ms |
10968 KB |
Output is correct |
63 |
Correct |
132 ms |
10488 KB |
Output is correct |
64 |
Correct |
124 ms |
10616 KB |
Output is correct |
65 |
Correct |
130 ms |
10744 KB |
Output is correct |
66 |
Correct |
132 ms |
10872 KB |
Output is correct |
67 |
Correct |
125 ms |
11132 KB |
Output is correct |
68 |
Correct |
128 ms |
11004 KB |
Output is correct |
69 |
Correct |
165 ms |
11332 KB |
Output is correct |
70 |
Correct |
131 ms |
11256 KB |
Output is correct |
71 |
Correct |
6 ms |
3448 KB |
Output is correct |
72 |
Correct |
9 ms |
3704 KB |
Output is correct |
73 |
Correct |
9 ms |
3704 KB |
Output is correct |
74 |
Correct |
10 ms |
3704 KB |
Output is correct |
75 |
Correct |
9 ms |
3704 KB |
Output is correct |
76 |
Correct |
10 ms |
3704 KB |
Output is correct |
77 |
Correct |
9 ms |
3704 KB |
Output is correct |
78 |
Correct |
9 ms |
3704 KB |
Output is correct |
79 |
Correct |
9 ms |
3704 KB |
Output is correct |
80 |
Correct |
138 ms |
10872 KB |
Output is correct |
81 |
Correct |
138 ms |
10872 KB |
Output is correct |
82 |
Correct |
128 ms |
10872 KB |
Output is correct |
83 |
Correct |
137 ms |
10872 KB |
Output is correct |
84 |
Correct |
9 ms |
3708 KB |
Output is correct |
85 |
Correct |
8 ms |
3576 KB |
Output is correct |
86 |
Correct |
9 ms |
3704 KB |
Output is correct |
87 |
Correct |
9 ms |
3704 KB |
Output is correct |
88 |
Correct |
9 ms |
3704 KB |
Output is correct |
89 |
Correct |
9 ms |
3704 KB |
Output is correct |
90 |
Correct |
8 ms |
3704 KB |
Output is correct |
91 |
Correct |
9 ms |
3704 KB |
Output is correct |
92 |
Correct |
10 ms |
3704 KB |
Output is correct |
93 |
Correct |
9 ms |
3704 KB |
Output is correct |
94 |
Correct |
7 ms |
3448 KB |
Output is correct |
95 |
Correct |
7 ms |
3448 KB |
Output is correct |
96 |
Correct |
7 ms |
3448 KB |
Output is correct |
97 |
Correct |
7 ms |
3448 KB |
Output is correct |
98 |
Correct |
6 ms |
3448 KB |
Output is correct |
99 |
Correct |
7 ms |
3448 KB |
Output is correct |
100 |
Correct |
7 ms |
3448 KB |
Output is correct |
101 |
Correct |
6 ms |
3448 KB |
Output is correct |
102 |
Correct |
7 ms |
3448 KB |
Output is correct |
103 |
Correct |
7 ms |
3444 KB |
Output is correct |
104 |
Correct |
15 ms |
4856 KB |
Output is correct |
105 |
Correct |
27 ms |
7672 KB |
Output is correct |
106 |
Correct |
7 ms |
3448 KB |
Output is correct |
107 |
Correct |
50 ms |
11256 KB |
Output is correct |
108 |
Correct |
77 ms |
17016 KB |
Output is correct |
109 |
Correct |
7 ms |
3704 KB |
Output is correct |
110 |
Correct |
105 ms |
16924 KB |
Output is correct |
111 |
Correct |
131 ms |
19832 KB |
Output is correct |
112 |
Correct |
7 ms |
3704 KB |
Output is correct |
113 |
Correct |
206 ms |
36472 KB |
Output is correct |
114 |
Incorrect |
25 ms |
5752 KB |
Output isn't correct |
115 |
Halted |
0 ms |
0 KB |
- |