Submission #109442

# Submission time Handle Problem Language Result Execution time Memory
109442 2019-05-06T14:41:50 Z amiratou Dreaming (IOI13_dreaming) C++14
65 / 100
122 ms 13172 KB
#include <bits/stdc++.h>
#include "dreaming.h"
using namespace std;
#define fi first
#define se second
#define INF (int)(1e9)
vector<vector<pair<int,int> > > vec;
bool vis[100005];
int maxi=0,a,idx=0;
vector<pair<int,int> > tree_d;
pair<int,int> p[100005],center[100005];
vector<int> nodes;
void dfs(int node,int d){
	nodes.push_back(node);
	if(d>maxi)
		a=node,maxi=d;
	vis[node]=1;
	for(auto child:vec[node])
		if(child.fi!=p[node].fi){
			p[child.fi]={node,child.se};
			dfs(child.fi,d+child.se);
		}
}
pair<int,int> findCenter(int node){
	maxi=0;
	dfs(node,0);
	for(auto i:nodes)
		p[i]={-1,-1};
	nodes.clear();
	int B=a,sum=0,mini=INF,c=node,sh=INF;
	maxi=0;
	if(B!=-1)
		dfs(B,0);
	nodes.clear();
	for(;a!=-1;sum+=p[a].se,a=p[a].fi){
		if(abs(maxi/2-sum)<mini)
			mini=abs(maxi/2-sum),c=a,sh=sum;
	}
	tree_d.push_back({maxi,idx});
	return {c,max(maxi-sh,0)};
}
int travelTime(int N, int M, int L, int A[], int B[], int T[]) {
	vec.resize(N);
	memset(p,-1,sizeof p);
	for (int i = 0; i < M; ++i)
	{
		vec[A[i]].push_back({B[i],T[i]});
		vec[B[i]].push_back({A[i],T[i]});
	}
	for (int i = 0; i < N; ++i)
		if(!vis[i])
			center[idx++]=findCenter(i);
	sort(tree_d.begin(),tree_d.end(),greater<pair<int,int> >());
	for (int i = 1; i < idx; ++i)
	{
		vec[center[tree_d[i].se].fi].push_back({center[tree_d[0].se].fi,L});
		vec[center[tree_d[0].se].fi].push_back({center[tree_d[i].se].fi,L});
	}
	maxi=0;
	memset(p,-1,sizeof p);
	dfs(0,0);
	nodes.clear();
	int b=a;
	memset(p,-1,sizeof p);
	maxi=0;
	dfs(b,0);
    return maxi;
}
# Verdict Execution time Memory Grader output
1 Correct 70 ms 12148 KB Output is correct
2 Correct 92 ms 12072 KB Output is correct
3 Correct 59 ms 8308 KB Output is correct
4 Correct 10 ms 2816 KB Output is correct
5 Correct 10 ms 2176 KB Output is correct
6 Correct 18 ms 3712 KB Output is correct
7 Correct 3 ms 1152 KB Output is correct
8 Correct 32 ms 5368 KB Output is correct
9 Correct 43 ms 6784 KB Output is correct
10 Correct 3 ms 1152 KB Output is correct
11 Correct 59 ms 8696 KB Output is correct
12 Correct 93 ms 10208 KB Output is correct
13 Correct 3 ms 1152 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 70 ms 12148 KB Output is correct
2 Correct 92 ms 12072 KB Output is correct
3 Correct 59 ms 8308 KB Output is correct
4 Correct 10 ms 2816 KB Output is correct
5 Correct 10 ms 2176 KB Output is correct
6 Correct 18 ms 3712 KB Output is correct
7 Correct 3 ms 1152 KB Output is correct
8 Correct 32 ms 5368 KB Output is correct
9 Correct 43 ms 6784 KB Output is correct
10 Correct 3 ms 1152 KB Output is correct
11 Correct 59 ms 8696 KB Output is correct
12 Correct 93 ms 10208 KB Output is correct
13 Correct 3 ms 1152 KB Output is correct
14 Correct 3 ms 1152 KB Output is correct
15 Correct 3 ms 1152 KB Output is correct
16 Correct 2 ms 1152 KB Output is correct
17 Correct 2 ms 1152 KB Output is correct
18 Correct 2 ms 1152 KB Output is correct
19 Correct 3 ms 1152 KB Output is correct
20 Correct 3 ms 1152 KB Output is correct
21 Correct 2 ms 1068 KB Output is correct
22 Correct 2 ms 1152 KB Output is correct
23 Correct 2 ms 1152 KB Output is correct
24 Correct 3 ms 1280 KB Output is correct
25 Correct 3 ms 1152 KB Output is correct
26 Correct 3 ms 1152 KB Output is correct
27 Correct 3 ms 1152 KB Output is correct
28 Correct 2 ms 1152 KB Output is correct
29 Correct 3 ms 1152 KB Output is correct
30 Correct 2 ms 1152 KB Output is correct
31 Correct 3 ms 1152 KB Output is correct
32 Correct 3 ms 1152 KB Output is correct
33 Correct 2 ms 1152 KB Output is correct
34 Correct 3 ms 1152 KB Output is correct
35 Correct 2 ms 1152 KB Output is correct
36 Correct 3 ms 1152 KB Output is correct
37 Correct 2 ms 1152 KB Output is correct
38 Correct 2 ms 1152 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 70 ms 12148 KB Output is correct
2 Correct 92 ms 12072 KB Output is correct
3 Correct 59 ms 8308 KB Output is correct
4 Correct 10 ms 2816 KB Output is correct
5 Correct 10 ms 2176 KB Output is correct
6 Correct 18 ms 3712 KB Output is correct
7 Correct 3 ms 1152 KB Output is correct
8 Correct 32 ms 5368 KB Output is correct
9 Correct 43 ms 6784 KB Output is correct
10 Correct 3 ms 1152 KB Output is correct
11 Correct 59 ms 8696 KB Output is correct
12 Correct 93 ms 10208 KB Output is correct
13 Correct 3 ms 1152 KB Output is correct
14 Correct 3 ms 1152 KB Output is correct
15 Correct 3 ms 1152 KB Output is correct
16 Correct 2 ms 1152 KB Output is correct
17 Correct 2 ms 1152 KB Output is correct
18 Correct 2 ms 1152 KB Output is correct
19 Correct 3 ms 1152 KB Output is correct
20 Correct 3 ms 1152 KB Output is correct
21 Correct 2 ms 1068 KB Output is correct
22 Correct 2 ms 1152 KB Output is correct
23 Correct 2 ms 1152 KB Output is correct
24 Correct 3 ms 1280 KB Output is correct
25 Correct 3 ms 1152 KB Output is correct
26 Correct 3 ms 1152 KB Output is correct
27 Correct 3 ms 1152 KB Output is correct
28 Correct 2 ms 1152 KB Output is correct
29 Correct 3 ms 1152 KB Output is correct
30 Correct 2 ms 1152 KB Output is correct
31 Correct 3 ms 1152 KB Output is correct
32 Correct 3 ms 1152 KB Output is correct
33 Correct 2 ms 1152 KB Output is correct
34 Correct 3 ms 1152 KB Output is correct
35 Correct 2 ms 1152 KB Output is correct
36 Correct 3 ms 1152 KB Output is correct
37 Correct 2 ms 1152 KB Output is correct
38 Correct 2 ms 1152 KB Output is correct
39 Correct 70 ms 12040 KB Output is correct
40 Correct 64 ms 12096 KB Output is correct
41 Correct 48 ms 8308 KB Output is correct
42 Correct 12 ms 2816 KB Output is correct
43 Correct 2 ms 1152 KB Output is correct
44 Correct 2 ms 1152 KB Output is correct
45 Correct 3 ms 1152 KB Output is correct
46 Correct 3 ms 1152 KB Output is correct
47 Correct 2 ms 1152 KB Output is correct
48 Correct 3 ms 1152 KB Output is correct
49 Correct 3 ms 1152 KB Output is correct
50 Correct 3 ms 1152 KB Output is correct
51 Correct 2 ms 1144 KB Output is correct
52 Correct 3 ms 1152 KB Output is correct
53 Correct 3 ms 1152 KB Output is correct
54 Correct 2 ms 1152 KB Output is correct
55 Correct 3 ms 1152 KB Output is correct
56 Correct 3 ms 1152 KB Output is correct
57 Correct 119 ms 9332 KB Output is correct
58 Correct 80 ms 9332 KB Output is correct
59 Correct 122 ms 9204 KB Output is correct
60 Correct 116 ms 9360 KB Output is correct
61 Correct 83 ms 9204 KB Output is correct
62 Correct 83 ms 9208 KB Output is correct
63 Correct 92 ms 9080 KB Output is correct
64 Correct 78 ms 9080 KB Output is correct
65 Correct 86 ms 9080 KB Output is correct
66 Correct 94 ms 9080 KB Output is correct
67 Correct 111 ms 9332 KB Output is correct
68 Correct 93 ms 9332 KB Output is correct
69 Correct 115 ms 9376 KB Output is correct
70 Correct 83 ms 9204 KB Output is correct
71 Correct 3 ms 1152 KB Output is correct
72 Correct 4 ms 1408 KB Output is correct
73 Correct 5 ms 1408 KB Output is correct
74 Correct 4 ms 1408 KB Output is correct
75 Correct 4 ms 1408 KB Output is correct
76 Correct 5 ms 1408 KB Output is correct
77 Correct 4 ms 1408 KB Output is correct
78 Correct 4 ms 1408 KB Output is correct
79 Correct 4 ms 1408 KB Output is correct
80 Correct 93 ms 9332 KB Output is correct
81 Correct 90 ms 9204 KB Output is correct
82 Correct 89 ms 9208 KB Output is correct
83 Correct 83 ms 9196 KB Output is correct
84 Correct 4 ms 1408 KB Output is correct
85 Correct 3 ms 1280 KB Output is correct
86 Correct 3 ms 1280 KB Output is correct
87 Correct 4 ms 1408 KB Output is correct
88 Correct 4 ms 1408 KB Output is correct
89 Correct 3 ms 1280 KB Output is correct
90 Correct 4 ms 1280 KB Output is correct
91 Correct 4 ms 1408 KB Output is correct
92 Correct 4 ms 1408 KB Output is correct
93 Correct 4 ms 1408 KB Output is correct
94 Correct 2 ms 1152 KB Output is correct
95 Correct 3 ms 1152 KB Output is correct
96 Correct 3 ms 1152 KB Output is correct
97 Correct 3 ms 1152 KB Output is correct
98 Correct 3 ms 1152 KB Output is correct
99 Correct 2 ms 1152 KB Output is correct
100 Correct 3 ms 1152 KB Output is correct
101 Correct 3 ms 1152 KB Output is correct
102 Correct 3 ms 1152 KB Output is correct
103 Correct 2 ms 1152 KB Output is correct
104 Correct 10 ms 2176 KB Output is correct
105 Correct 17 ms 3584 KB Output is correct
106 Correct 3 ms 1152 KB Output is correct
107 Correct 31 ms 5368 KB Output is correct
108 Correct 44 ms 6776 KB Output is correct
109 Correct 3 ms 1152 KB Output is correct
110 Correct 73 ms 8868 KB Output is correct
111 Correct 84 ms 10224 KB Output is correct
112 Correct 3 ms 1152 KB Output is correct
113 Correct 107 ms 13172 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 45 ms 8996 KB Output is correct
2 Correct 49 ms 9032 KB Output is correct
3 Correct 40 ms 9000 KB Output is correct
4 Correct 45 ms 8992 KB Output is correct
5 Correct 40 ms 8868 KB Output is correct
6 Correct 44 ms 9712 KB Output is correct
7 Correct 45 ms 9340 KB Output is correct
8 Correct 47 ms 8768 KB Output is correct
9 Correct 44 ms 8760 KB Output is correct
10 Correct 49 ms 9212 KB Output is correct
11 Correct 3 ms 1152 KB Output is correct
12 Correct 21 ms 9972 KB Output is correct
13 Correct 23 ms 9972 KB Output is correct
14 Correct 21 ms 9972 KB Output is correct
15 Correct 20 ms 9972 KB Output is correct
16 Correct 21 ms 9964 KB Output is correct
17 Correct 20 ms 9972 KB Output is correct
18 Correct 22 ms 9972 KB Output is correct
19 Correct 21 ms 9972 KB Output is correct
20 Correct 2 ms 1152 KB Output is correct
21 Correct 3 ms 1152 KB Output is correct
22 Correct 3 ms 1408 KB Output is correct
23 Correct 20 ms 9972 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 70 ms 12148 KB Output is correct
2 Correct 92 ms 12072 KB Output is correct
3 Correct 59 ms 8308 KB Output is correct
4 Correct 10 ms 2816 KB Output is correct
5 Correct 10 ms 2176 KB Output is correct
6 Correct 18 ms 3712 KB Output is correct
7 Correct 3 ms 1152 KB Output is correct
8 Correct 32 ms 5368 KB Output is correct
9 Correct 43 ms 6784 KB Output is correct
10 Correct 3 ms 1152 KB Output is correct
11 Correct 59 ms 8696 KB Output is correct
12 Correct 93 ms 10208 KB Output is correct
13 Correct 3 ms 1152 KB Output is correct
14 Correct 3 ms 1152 KB Output is correct
15 Correct 3 ms 1280 KB Output is correct
16 Correct 4 ms 1408 KB Output is correct
17 Correct 3 ms 1280 KB Output is correct
18 Correct 3 ms 1280 KB Output is correct
19 Correct 4 ms 1408 KB Output is correct
20 Correct 3 ms 1280 KB Output is correct
21 Correct 4 ms 1280 KB Output is correct
22 Correct 4 ms 1408 KB Output is correct
23 Correct 3 ms 1152 KB Output is correct
24 Correct 3 ms 1152 KB Output is correct
25 Correct 3 ms 1152 KB Output is correct
26 Correct 5 ms 1152 KB Output is correct
27 Correct 3 ms 1152 KB Output is correct
28 Correct 3 ms 1152 KB Output is correct
29 Correct 3 ms 1152 KB Output is correct
30 Correct 3 ms 1152 KB Output is correct
31 Correct 2 ms 1152 KB Output is correct
32 Correct 2 ms 1152 KB Output is correct
33 Correct 2 ms 1152 KB Output is correct
34 Correct 3 ms 1152 KB Output is correct
35 Correct 2 ms 1152 KB Output is correct
36 Correct 2 ms 1152 KB Output is correct
37 Correct 3 ms 1152 KB Output is correct
38 Correct 3 ms 1152 KB Output is correct
39 Correct 3 ms 1152 KB Output is correct
40 Correct 2 ms 1152 KB Output is correct
41 Correct 3 ms 1152 KB Output is correct
42 Correct 4 ms 1408 KB Output is correct
43 Correct 4 ms 1408 KB Output is correct
44 Correct 4 ms 1408 KB Output is correct
45 Correct 3 ms 1408 KB Output is correct
46 Correct 4 ms 1408 KB Output is correct
47 Correct 5 ms 1408 KB Output is correct
48 Correct 4 ms 1416 KB Output is correct
49 Incorrect 3 ms 1408 KB Output isn't correct
50 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 70 ms 12148 KB Output is correct
2 Correct 92 ms 12072 KB Output is correct
3 Correct 59 ms 8308 KB Output is correct
4 Correct 10 ms 2816 KB Output is correct
5 Correct 10 ms 2176 KB Output is correct
6 Correct 18 ms 3712 KB Output is correct
7 Correct 3 ms 1152 KB Output is correct
8 Correct 32 ms 5368 KB Output is correct
9 Correct 43 ms 6784 KB Output is correct
10 Correct 3 ms 1152 KB Output is correct
11 Correct 59 ms 8696 KB Output is correct
12 Correct 93 ms 10208 KB Output is correct
13 Correct 3 ms 1152 KB Output is correct
14 Correct 3 ms 1152 KB Output is correct
15 Correct 3 ms 1152 KB Output is correct
16 Correct 2 ms 1152 KB Output is correct
17 Correct 2 ms 1152 KB Output is correct
18 Correct 2 ms 1152 KB Output is correct
19 Correct 3 ms 1152 KB Output is correct
20 Correct 3 ms 1152 KB Output is correct
21 Correct 2 ms 1068 KB Output is correct
22 Correct 2 ms 1152 KB Output is correct
23 Correct 2 ms 1152 KB Output is correct
24 Correct 3 ms 1280 KB Output is correct
25 Correct 3 ms 1152 KB Output is correct
26 Correct 3 ms 1152 KB Output is correct
27 Correct 3 ms 1152 KB Output is correct
28 Correct 2 ms 1152 KB Output is correct
29 Correct 3 ms 1152 KB Output is correct
30 Correct 2 ms 1152 KB Output is correct
31 Correct 3 ms 1152 KB Output is correct
32 Correct 3 ms 1152 KB Output is correct
33 Correct 2 ms 1152 KB Output is correct
34 Correct 3 ms 1152 KB Output is correct
35 Correct 2 ms 1152 KB Output is correct
36 Correct 3 ms 1152 KB Output is correct
37 Correct 2 ms 1152 KB Output is correct
38 Correct 2 ms 1152 KB Output is correct
39 Correct 70 ms 12040 KB Output is correct
40 Correct 64 ms 12096 KB Output is correct
41 Correct 48 ms 8308 KB Output is correct
42 Correct 12 ms 2816 KB Output is correct
43 Correct 2 ms 1152 KB Output is correct
44 Correct 2 ms 1152 KB Output is correct
45 Correct 3 ms 1152 KB Output is correct
46 Correct 3 ms 1152 KB Output is correct
47 Correct 2 ms 1152 KB Output is correct
48 Correct 3 ms 1152 KB Output is correct
49 Correct 3 ms 1152 KB Output is correct
50 Correct 3 ms 1152 KB Output is correct
51 Correct 2 ms 1144 KB Output is correct
52 Correct 3 ms 1152 KB Output is correct
53 Correct 3 ms 1152 KB Output is correct
54 Correct 2 ms 1152 KB Output is correct
55 Correct 3 ms 1152 KB Output is correct
56 Correct 3 ms 1152 KB Output is correct
57 Correct 119 ms 9332 KB Output is correct
58 Correct 80 ms 9332 KB Output is correct
59 Correct 122 ms 9204 KB Output is correct
60 Correct 116 ms 9360 KB Output is correct
61 Correct 83 ms 9204 KB Output is correct
62 Correct 83 ms 9208 KB Output is correct
63 Correct 92 ms 9080 KB Output is correct
64 Correct 78 ms 9080 KB Output is correct
65 Correct 86 ms 9080 KB Output is correct
66 Correct 94 ms 9080 KB Output is correct
67 Correct 111 ms 9332 KB Output is correct
68 Correct 93 ms 9332 KB Output is correct
69 Correct 115 ms 9376 KB Output is correct
70 Correct 83 ms 9204 KB Output is correct
71 Correct 3 ms 1152 KB Output is correct
72 Correct 4 ms 1408 KB Output is correct
73 Correct 5 ms 1408 KB Output is correct
74 Correct 4 ms 1408 KB Output is correct
75 Correct 4 ms 1408 KB Output is correct
76 Correct 5 ms 1408 KB Output is correct
77 Correct 4 ms 1408 KB Output is correct
78 Correct 4 ms 1408 KB Output is correct
79 Correct 4 ms 1408 KB Output is correct
80 Correct 93 ms 9332 KB Output is correct
81 Correct 90 ms 9204 KB Output is correct
82 Correct 89 ms 9208 KB Output is correct
83 Correct 83 ms 9196 KB Output is correct
84 Correct 4 ms 1408 KB Output is correct
85 Correct 3 ms 1280 KB Output is correct
86 Correct 3 ms 1280 KB Output is correct
87 Correct 4 ms 1408 KB Output is correct
88 Correct 4 ms 1408 KB Output is correct
89 Correct 3 ms 1280 KB Output is correct
90 Correct 4 ms 1280 KB Output is correct
91 Correct 4 ms 1408 KB Output is correct
92 Correct 4 ms 1408 KB Output is correct
93 Correct 4 ms 1408 KB Output is correct
94 Correct 2 ms 1152 KB Output is correct
95 Correct 3 ms 1152 KB Output is correct
96 Correct 3 ms 1152 KB Output is correct
97 Correct 3 ms 1152 KB Output is correct
98 Correct 3 ms 1152 KB Output is correct
99 Correct 2 ms 1152 KB Output is correct
100 Correct 3 ms 1152 KB Output is correct
101 Correct 3 ms 1152 KB Output is correct
102 Correct 3 ms 1152 KB Output is correct
103 Correct 2 ms 1152 KB Output is correct
104 Correct 10 ms 2176 KB Output is correct
105 Correct 17 ms 3584 KB Output is correct
106 Correct 3 ms 1152 KB Output is correct
107 Correct 31 ms 5368 KB Output is correct
108 Correct 44 ms 6776 KB Output is correct
109 Correct 3 ms 1152 KB Output is correct
110 Correct 73 ms 8868 KB Output is correct
111 Correct 84 ms 10224 KB Output is correct
112 Correct 3 ms 1152 KB Output is correct
113 Correct 107 ms 13172 KB Output is correct
114 Correct 45 ms 8996 KB Output is correct
115 Correct 49 ms 9032 KB Output is correct
116 Correct 40 ms 9000 KB Output is correct
117 Correct 45 ms 8992 KB Output is correct
118 Correct 40 ms 8868 KB Output is correct
119 Correct 44 ms 9712 KB Output is correct
120 Correct 45 ms 9340 KB Output is correct
121 Correct 47 ms 8768 KB Output is correct
122 Correct 44 ms 8760 KB Output is correct
123 Correct 49 ms 9212 KB Output is correct
124 Correct 3 ms 1152 KB Output is correct
125 Correct 21 ms 9972 KB Output is correct
126 Correct 23 ms 9972 KB Output is correct
127 Correct 21 ms 9972 KB Output is correct
128 Correct 20 ms 9972 KB Output is correct
129 Correct 21 ms 9964 KB Output is correct
130 Correct 20 ms 9972 KB Output is correct
131 Correct 22 ms 9972 KB Output is correct
132 Correct 21 ms 9972 KB Output is correct
133 Correct 2 ms 1152 KB Output is correct
134 Correct 3 ms 1152 KB Output is correct
135 Correct 3 ms 1408 KB Output is correct
136 Correct 20 ms 9972 KB Output is correct
137 Correct 3 ms 1152 KB Output is correct
138 Correct 3 ms 1280 KB Output is correct
139 Correct 4 ms 1408 KB Output is correct
140 Correct 3 ms 1280 KB Output is correct
141 Correct 3 ms 1280 KB Output is correct
142 Correct 4 ms 1408 KB Output is correct
143 Correct 3 ms 1280 KB Output is correct
144 Correct 4 ms 1280 KB Output is correct
145 Correct 4 ms 1408 KB Output is correct
146 Correct 3 ms 1152 KB Output is correct
147 Correct 3 ms 1152 KB Output is correct
148 Correct 3 ms 1152 KB Output is correct
149 Correct 5 ms 1152 KB Output is correct
150 Correct 3 ms 1152 KB Output is correct
151 Correct 3 ms 1152 KB Output is correct
152 Correct 3 ms 1152 KB Output is correct
153 Correct 3 ms 1152 KB Output is correct
154 Correct 2 ms 1152 KB Output is correct
155 Correct 2 ms 1152 KB Output is correct
156 Correct 2 ms 1152 KB Output is correct
157 Correct 3 ms 1152 KB Output is correct
158 Correct 2 ms 1152 KB Output is correct
159 Correct 2 ms 1152 KB Output is correct
160 Correct 3 ms 1152 KB Output is correct
161 Correct 3 ms 1152 KB Output is correct
162 Correct 3 ms 1152 KB Output is correct
163 Correct 2 ms 1152 KB Output is correct
164 Correct 3 ms 1152 KB Output is correct
165 Correct 4 ms 1408 KB Output is correct
166 Correct 4 ms 1408 KB Output is correct
167 Correct 4 ms 1408 KB Output is correct
168 Correct 3 ms 1408 KB Output is correct
169 Correct 4 ms 1408 KB Output is correct
170 Correct 5 ms 1408 KB Output is correct
171 Correct 4 ms 1416 KB Output is correct
172 Incorrect 3 ms 1408 KB Output isn't correct
173 Halted 0 ms 0 KB -