Submission #232651

# Submission time Handle Problem Language Result Execution time Memory
232651 2020-05-17T17:53:15 Z crossing0ver Traffic (IOI10_traffic) C++17
50 / 100
5000 ms 29688 KB
#include<bits/stdc++.h>
using namespace std; 
int dp[1000006],sum[1000001], C[1000006] , tot; 
vector <int> adj[1000005];
void dfs(int v,int p) {
	dp[v] = sum[v] = 0;
//	int s = 0;
//	int r = 0;
	for (int i:adj[v]) {
		if (i != p) {
			dfs (i,v);
			dp[v] = max(dp[v], sum[i] + C[i]);
			sum[v] += sum[i] + C[i];
		}
	}
}

int LocateCentre(int n,int P[],int S[],int D[]) {
	  for (int i = 0; i < n-1; i++)
	  	adj[S[i]].push_back(D[i]),
	  	adj[D[i]].push_back(S[i]),
	  	C[i] = P[i], tot += C[i];
	  	C[n-1] = P[n-1];
	pair<int,int> ans = {INT_MAX,-1};
	for (int i = 0; i < n; i++) {
		dfs(i,-1);
		ans = min(ans,{dp[i],i});
	}
	return ans.second;
}     /*
int main(){
	static int N,P[1000000],S[1000000],D[1000000];
   int i;
   scanf("%d",&N);
   for (i=0;i<N;i++) scanf("%d",&P[i]);
   for (i=0;i<N-1;i++) scanf("%d%d",&S[i],&D[i]);
   int r = LocateCentre(N,P,S,D);
   printf("%d\n",r);
   return 0;
}                   */

Compilation message

traffic.cpp: In function 'int LocateCentre(int, int*, int*, int*)':
traffic.cpp:19:4: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
    for (int i = 0; i < n-1; i++)
    ^~~
traffic.cpp:23:5: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
     C[n-1] = P[n-1];
     ^
# Verdict Execution time Memory Grader output
1 Correct 19 ms 23808 KB Output is correct
2 Correct 19 ms 23808 KB Output is correct
3 Correct 19 ms 23936 KB Output is correct
4 Correct 19 ms 23808 KB Output is correct
5 Correct 19 ms 23808 KB Output is correct
6 Correct 19 ms 23808 KB Output is correct
7 Correct 19 ms 23892 KB Output is correct
8 Correct 19 ms 23808 KB Output is correct
9 Correct 19 ms 23808 KB Output is correct
10 Correct 19 ms 23808 KB Output is correct
11 Correct 19 ms 23936 KB Output is correct
12 Correct 20 ms 23808 KB Output is correct
13 Correct 19 ms 23808 KB Output is correct
14 Correct 19 ms 23808 KB Output is correct
15 Correct 20 ms 23808 KB Output is correct
16 Correct 19 ms 23808 KB Output is correct
17 Correct 19 ms 23808 KB Output is correct
18 Correct 19 ms 23936 KB Output is correct
19 Correct 19 ms 23808 KB Output is correct
20 Correct 19 ms 23808 KB Output is correct
21 Correct 19 ms 23808 KB Output is correct
22 Correct 20 ms 23936 KB Output is correct
23 Correct 19 ms 23808 KB Output is correct
24 Correct 20 ms 23808 KB Output is correct
25 Correct 20 ms 23808 KB Output is correct
26 Correct 20 ms 23936 KB Output is correct
27 Correct 20 ms 23936 KB Output is correct
28 Correct 21 ms 23808 KB Output is correct
29 Correct 21 ms 23936 KB Output is correct
30 Correct 21 ms 23936 KB Output is correct
31 Correct 22 ms 23936 KB Output is correct
32 Correct 23 ms 24064 KB Output is correct
33 Correct 23 ms 23936 KB Output is correct
34 Correct 21 ms 23808 KB Output is correct
35 Correct 23 ms 23936 KB Output is correct
36 Correct 24 ms 23936 KB Output is correct
37 Correct 25 ms 23936 KB Output is correct
38 Correct 27 ms 23936 KB Output is correct
39 Correct 26 ms 24064 KB Output is correct
40 Correct 27 ms 23936 KB Output is correct
41 Correct 29 ms 23936 KB Output is correct
42 Correct 30 ms 23936 KB Output is correct
43 Correct 19 ms 23808 KB Output is correct
44 Correct 19 ms 23936 KB Output is correct
45 Correct 19 ms 23808 KB Output is correct
46 Correct 20 ms 23808 KB Output is correct
47 Correct 20 ms 23808 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 19 ms 23808 KB Output is correct
2 Correct 19 ms 23808 KB Output is correct
3 Correct 19 ms 23936 KB Output is correct
4 Correct 19 ms 23808 KB Output is correct
5 Correct 19 ms 23808 KB Output is correct
6 Correct 19 ms 23808 KB Output is correct
7 Correct 19 ms 23892 KB Output is correct
8 Correct 19 ms 23808 KB Output is correct
9 Correct 19 ms 23808 KB Output is correct
10 Correct 19 ms 23808 KB Output is correct
11 Correct 19 ms 23936 KB Output is correct
12 Correct 20 ms 23808 KB Output is correct
13 Correct 19 ms 23808 KB Output is correct
14 Correct 19 ms 23808 KB Output is correct
15 Correct 20 ms 23808 KB Output is correct
16 Correct 19 ms 23808 KB Output is correct
17 Correct 19 ms 23808 KB Output is correct
18 Correct 19 ms 23936 KB Output is correct
19 Correct 19 ms 23808 KB Output is correct
20 Correct 19 ms 23808 KB Output is correct
21 Correct 19 ms 23808 KB Output is correct
22 Correct 20 ms 23936 KB Output is correct
23 Correct 19 ms 23808 KB Output is correct
24 Correct 20 ms 23808 KB Output is correct
25 Correct 20 ms 23808 KB Output is correct
26 Correct 20 ms 23936 KB Output is correct
27 Correct 20 ms 23936 KB Output is correct
28 Correct 21 ms 23808 KB Output is correct
29 Correct 21 ms 23936 KB Output is correct
30 Correct 21 ms 23936 KB Output is correct
31 Correct 22 ms 23936 KB Output is correct
32 Correct 23 ms 24064 KB Output is correct
33 Correct 23 ms 23936 KB Output is correct
34 Correct 21 ms 23808 KB Output is correct
35 Correct 23 ms 23936 KB Output is correct
36 Correct 24 ms 23936 KB Output is correct
37 Correct 25 ms 23936 KB Output is correct
38 Correct 27 ms 23936 KB Output is correct
39 Correct 26 ms 24064 KB Output is correct
40 Correct 27 ms 23936 KB Output is correct
41 Correct 29 ms 23936 KB Output is correct
42 Correct 30 ms 23936 KB Output is correct
43 Correct 19 ms 23808 KB Output is correct
44 Correct 19 ms 23936 KB Output is correct
45 Correct 19 ms 23808 KB Output is correct
46 Correct 20 ms 23808 KB Output is correct
47 Correct 20 ms 23808 KB Output is correct
48 Correct 18 ms 23808 KB Output is correct
49 Correct 19 ms 23808 KB Output is correct
50 Correct 19 ms 23808 KB Output is correct
51 Correct 20 ms 23808 KB Output is correct
52 Correct 19 ms 23808 KB Output is correct
53 Correct 19 ms 23936 KB Output is correct
54 Correct 19 ms 23936 KB Output is correct
55 Correct 19 ms 23808 KB Output is correct
56 Correct 19 ms 23808 KB Output is correct
57 Correct 19 ms 23936 KB Output is correct
58 Correct 20 ms 23776 KB Output is correct
59 Correct 19 ms 23808 KB Output is correct
60 Correct 21 ms 23860 KB Output is correct
61 Correct 19 ms 23808 KB Output is correct
62 Correct 25 ms 23808 KB Output is correct
63 Correct 18 ms 23808 KB Output is correct
64 Correct 19 ms 23808 KB Output is correct
65 Correct 19 ms 23808 KB Output is correct
66 Correct 18 ms 23808 KB Output is correct
67 Correct 17 ms 23808 KB Output is correct
68 Execution timed out 5039 ms 29688 KB Time limit exceeded
69 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 19 ms 23808 KB Output is correct
2 Correct 19 ms 23808 KB Output is correct
3 Correct 19 ms 23936 KB Output is correct
4 Correct 19 ms 23808 KB Output is correct
5 Correct 19 ms 23808 KB Output is correct
6 Correct 19 ms 23808 KB Output is correct
7 Correct 19 ms 23892 KB Output is correct
8 Correct 19 ms 23808 KB Output is correct
9 Correct 19 ms 23808 KB Output is correct
10 Correct 19 ms 23808 KB Output is correct
11 Correct 19 ms 23936 KB Output is correct
12 Correct 20 ms 23808 KB Output is correct
13 Correct 19 ms 23808 KB Output is correct
14 Correct 19 ms 23808 KB Output is correct
15 Correct 20 ms 23808 KB Output is correct
16 Correct 19 ms 23808 KB Output is correct
17 Correct 19 ms 23808 KB Output is correct
18 Correct 19 ms 23936 KB Output is correct
19 Correct 19 ms 23808 KB Output is correct
20 Correct 19 ms 23808 KB Output is correct
21 Correct 19 ms 23808 KB Output is correct
22 Correct 20 ms 23936 KB Output is correct
23 Correct 19 ms 23808 KB Output is correct
24 Correct 20 ms 23808 KB Output is correct
25 Correct 20 ms 23808 KB Output is correct
26 Correct 20 ms 23936 KB Output is correct
27 Correct 20 ms 23936 KB Output is correct
28 Correct 21 ms 23808 KB Output is correct
29 Correct 21 ms 23936 KB Output is correct
30 Correct 21 ms 23936 KB Output is correct
31 Correct 22 ms 23936 KB Output is correct
32 Correct 23 ms 24064 KB Output is correct
33 Correct 23 ms 23936 KB Output is correct
34 Correct 21 ms 23808 KB Output is correct
35 Correct 23 ms 23936 KB Output is correct
36 Correct 24 ms 23936 KB Output is correct
37 Correct 25 ms 23936 KB Output is correct
38 Correct 27 ms 23936 KB Output is correct
39 Correct 26 ms 24064 KB Output is correct
40 Correct 27 ms 23936 KB Output is correct
41 Correct 29 ms 23936 KB Output is correct
42 Correct 30 ms 23936 KB Output is correct
43 Correct 19 ms 23808 KB Output is correct
44 Correct 19 ms 23936 KB Output is correct
45 Correct 19 ms 23808 KB Output is correct
46 Correct 20 ms 23808 KB Output is correct
47 Correct 20 ms 23808 KB Output is correct
48 Correct 20 ms 23808 KB Output is correct
49 Correct 19 ms 23808 KB Output is correct
50 Correct 21 ms 23808 KB Output is correct
51 Correct 20 ms 23808 KB Output is correct
52 Correct 20 ms 23936 KB Output is correct
53 Correct 19 ms 23808 KB Output is correct
54 Correct 19 ms 23936 KB Output is correct
55 Correct 19 ms 23808 KB Output is correct
56 Correct 19 ms 23936 KB Output is correct
57 Correct 18 ms 23808 KB Output is correct
58 Correct 19 ms 23808 KB Output is correct
59 Correct 20 ms 23808 KB Output is correct
60 Correct 19 ms 23936 KB Output is correct
61 Correct 19 ms 23808 KB Output is correct
62 Correct 19 ms 23808 KB Output is correct
63 Correct 19 ms 23808 KB Output is correct
64 Correct 20 ms 23808 KB Output is correct
65 Correct 20 ms 23808 KB Output is correct
66 Correct 20 ms 23936 KB Output is correct
67 Correct 21 ms 23808 KB Output is correct
68 Correct 19 ms 23936 KB Output is correct
69 Correct 20 ms 23808 KB Output is correct
70 Correct 19 ms 23808 KB Output is correct
71 Correct 19 ms 23808 KB Output is correct
72 Correct 19 ms 23808 KB Output is correct
73 Correct 21 ms 23936 KB Output is correct
74 Correct 19 ms 23936 KB Output is correct
75 Correct 19 ms 23808 KB Output is correct
76 Correct 20 ms 23808 KB Output is correct
77 Correct 21 ms 23936 KB Output is correct
78 Correct 20 ms 23936 KB Output is correct
79 Correct 21 ms 23936 KB Output is correct
80 Correct 22 ms 23808 KB Output is correct
81 Correct 20 ms 23808 KB Output is correct
82 Correct 23 ms 23936 KB Output is correct
83 Correct 24 ms 23912 KB Output is correct
84 Correct 24 ms 23936 KB Output is correct
85 Correct 26 ms 23936 KB Output is correct
86 Correct 26 ms 23936 KB Output is correct
87 Correct 28 ms 23936 KB Output is correct
88 Correct 32 ms 23936 KB Output is correct
89 Correct 32 ms 23936 KB Output is correct
90 Correct 32 ms 23936 KB Output is correct
91 Correct 34 ms 23936 KB Output is correct
92 Correct 20 ms 23808 KB Output is correct
93 Correct 38 ms 23936 KB Output is correct
94 Correct 22 ms 23936 KB Output is correct
95 Correct 29 ms 24064 KB Output is correct
96 Correct 19 ms 23808 KB Output is correct
97 Correct 20 ms 23936 KB Output is correct
98 Correct 20 ms 23808 KB Output is correct
99 Correct 20 ms 23808 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 19 ms 23808 KB Output is correct
2 Correct 19 ms 23808 KB Output is correct
3 Correct 19 ms 23936 KB Output is correct
4 Correct 19 ms 23808 KB Output is correct
5 Correct 19 ms 23808 KB Output is correct
6 Correct 19 ms 23808 KB Output is correct
7 Correct 19 ms 23892 KB Output is correct
8 Correct 19 ms 23808 KB Output is correct
9 Correct 19 ms 23808 KB Output is correct
10 Correct 19 ms 23808 KB Output is correct
11 Correct 19 ms 23936 KB Output is correct
12 Correct 20 ms 23808 KB Output is correct
13 Correct 19 ms 23808 KB Output is correct
14 Correct 19 ms 23808 KB Output is correct
15 Correct 20 ms 23808 KB Output is correct
16 Correct 19 ms 23808 KB Output is correct
17 Correct 19 ms 23808 KB Output is correct
18 Correct 19 ms 23936 KB Output is correct
19 Correct 19 ms 23808 KB Output is correct
20 Correct 19 ms 23808 KB Output is correct
21 Correct 19 ms 23808 KB Output is correct
22 Correct 20 ms 23936 KB Output is correct
23 Correct 19 ms 23808 KB Output is correct
24 Correct 20 ms 23808 KB Output is correct
25 Correct 20 ms 23808 KB Output is correct
26 Correct 20 ms 23936 KB Output is correct
27 Correct 20 ms 23936 KB Output is correct
28 Correct 21 ms 23808 KB Output is correct
29 Correct 21 ms 23936 KB Output is correct
30 Correct 21 ms 23936 KB Output is correct
31 Correct 22 ms 23936 KB Output is correct
32 Correct 23 ms 24064 KB Output is correct
33 Correct 23 ms 23936 KB Output is correct
34 Correct 21 ms 23808 KB Output is correct
35 Correct 23 ms 23936 KB Output is correct
36 Correct 24 ms 23936 KB Output is correct
37 Correct 25 ms 23936 KB Output is correct
38 Correct 27 ms 23936 KB Output is correct
39 Correct 26 ms 24064 KB Output is correct
40 Correct 27 ms 23936 KB Output is correct
41 Correct 29 ms 23936 KB Output is correct
42 Correct 30 ms 23936 KB Output is correct
43 Correct 19 ms 23808 KB Output is correct
44 Correct 19 ms 23936 KB Output is correct
45 Correct 19 ms 23808 KB Output is correct
46 Correct 20 ms 23808 KB Output is correct
47 Correct 20 ms 23808 KB Output is correct
48 Correct 18 ms 23808 KB Output is correct
49 Correct 19 ms 23808 KB Output is correct
50 Correct 19 ms 23808 KB Output is correct
51 Correct 20 ms 23808 KB Output is correct
52 Correct 19 ms 23808 KB Output is correct
53 Correct 19 ms 23936 KB Output is correct
54 Correct 19 ms 23936 KB Output is correct
55 Correct 19 ms 23808 KB Output is correct
56 Correct 19 ms 23808 KB Output is correct
57 Correct 19 ms 23936 KB Output is correct
58 Correct 20 ms 23776 KB Output is correct
59 Correct 19 ms 23808 KB Output is correct
60 Correct 21 ms 23860 KB Output is correct
61 Correct 19 ms 23808 KB Output is correct
62 Correct 25 ms 23808 KB Output is correct
63 Correct 18 ms 23808 KB Output is correct
64 Correct 19 ms 23808 KB Output is correct
65 Correct 19 ms 23808 KB Output is correct
66 Correct 18 ms 23808 KB Output is correct
67 Correct 17 ms 23808 KB Output is correct
68 Execution timed out 5039 ms 29688 KB Time limit exceeded
69 Halted 0 ms 0 KB -