Submission #233898

# Submission time Handle Problem Language Result Execution time Memory
233898 2020-05-22T09:36:08 Z anubhavdhar Traffic (IOI10_traffic) C++14
50 / 100
566 ms 137336 KB
#include<bits/stdc++.h>
#include "traffic.h"
 
#define ll long long int
#define pb push_back
#define mp make_pair
#define FOR(i,n) for(i=0;i<(n);++i)
#define FORe(i,n) for(i=1;i<=(n);++i)
#define FORr(i,a,b) for(i=(a);i<(b);++i)
#define FORrev(i,n) for(i=(n);i>=0;--i)
#define F0R(i,n) for(int i=0;i<(n);++i)
#define F0Re(i,n) for(int i=1;i<=(n);++i)
#define F0Rr(i,a,b) for(ll i=(a);i<(b);++i)
#define F0Rrev(i,n) for(int i=(n);i>=0;--i)
#define ii pair<ll,ll>
#define vi vector<ll>
#define vii vector<ii>
#define ff first 
#define ss second
#define cd complex<double>
#define vcd vector<cd>
#define ldd long double
#define dbgLine cout<<"Line : "<<__LINE__<<'\n'
#define all(x) (x).begin(),(x).end()
 
using namespace std;
/*
const short int __PRECISION = 10;
 
const ll MOD = 1e9+7;
const ll INF = 1e17 + 1101;
const ll LOGN = 17;
const ll MAXN = 1e6+5;
const ll ROOTN = 320;
 
const ldd PI = acos(-1);
const ldd EPS = 1e-7;*/
 
#define MAXN 1000006
#define INF 100000000000000017
 
vector<ll> g[MAXN];
ll People[MAXN], dp[MAXN], sum[MAXN], sm;
 
ll dfs(ll a, ll par)
{
	dp[a] = 0;
	sum[a] = People[a];
	for(ll b : g[a])
		if(b != par)
			dp[a] = max(dp[a], dfs(b, a)), sum[a] += sum[b];
	return dp[a] + People[a];
}
 
 
 
int LocateCentre(int N, int* P, int* S, int* D)
{
	sm = 0;
	F0R(i, N)
		g[i].clear(), People[i] = P[i], sm += P[i];
	F0R(i, N-1)
	{
		g[S[i]].pb(D[i]);
		g[D[i]].pb(S[i]);
	}
	dfs(1, -1);
	pair<ll, int> mx = mp(INF, -1);
	F0R(i, N)
		mx = min(mx, mp(max(dp[i],sm - sum[i]),i));
	//cerr<<mx.ff<<' '<<mx.ss<<'\n';
	return mx.ss;
}
/*
int main()
{
 
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
 
	int N;
	cin>>N;
	int P[N], S[N], D[N];
	F0R(i, N)
		cin>>P[i];
	F0R(i, N-1)
		cin>>S[i]>>D[i];
	cout<<LocateCenter(N, P, S, D);
	return 0;
}*/
# Verdict Execution time Memory Grader output
1 Correct 19 ms 23808 KB Output is correct
2 Correct 18 ms 23808 KB Output is correct
3 Correct 18 ms 23808 KB Output is correct
4 Correct 19 ms 23808 KB Output is correct
5 Correct 18 ms 23808 KB Output is correct
6 Correct 19 ms 23808 KB Output is correct
7 Correct 18 ms 23808 KB Output is correct
8 Correct 19 ms 23808 KB Output is correct
9 Correct 18 ms 23808 KB Output is correct
10 Correct 18 ms 23808 KB Output is correct
11 Correct 18 ms 23808 KB Output is correct
12 Correct 18 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 18 ms 23808 KB Output is correct
16 Correct 18 ms 23808 KB Output is correct
17 Correct 18 ms 23808 KB Output is correct
18 Correct 19 ms 23808 KB Output is correct
19 Correct 18 ms 23808 KB Output is correct
20 Correct 18 ms 23808 KB Output is correct
21 Correct 18 ms 23808 KB Output is correct
22 Correct 18 ms 23808 KB Output is correct
23 Correct 18 ms 23808 KB Output is correct
24 Correct 18 ms 23808 KB Output is correct
25 Correct 19 ms 23808 KB Output is correct
26 Correct 18 ms 23808 KB Output is correct
27 Correct 19 ms 23808 KB Output is correct
28 Correct 20 ms 23936 KB Output is correct
29 Correct 20 ms 23808 KB Output is correct
30 Correct 18 ms 23936 KB Output is correct
31 Correct 19 ms 23936 KB Output is correct
32 Correct 19 ms 23936 KB Output is correct
33 Correct 18 ms 23936 KB Output is correct
34 Correct 18 ms 23808 KB Output is correct
35 Correct 19 ms 23936 KB Output is correct
36 Correct 18 ms 23936 KB Output is correct
37 Correct 18 ms 23936 KB Output is correct
38 Correct 18 ms 23936 KB Output is correct
39 Correct 19 ms 23936 KB Output is correct
40 Correct 20 ms 23936 KB Output is correct
41 Correct 19 ms 23936 KB Output is correct
42 Correct 19 ms 23936 KB Output is correct
43 Correct 18 ms 23808 KB Output is correct
44 Correct 19 ms 23808 KB Output is correct
45 Correct 20 ms 23808 KB Output is correct
46 Correct 18 ms 23808 KB Output is correct
47 Correct 18 ms 23808 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 19 ms 23808 KB Output is correct
2 Correct 18 ms 23808 KB Output is correct
3 Correct 18 ms 23808 KB Output is correct
4 Correct 19 ms 23808 KB Output is correct
5 Correct 18 ms 23808 KB Output is correct
6 Correct 19 ms 23808 KB Output is correct
7 Correct 18 ms 23808 KB Output is correct
8 Correct 19 ms 23808 KB Output is correct
9 Correct 18 ms 23808 KB Output is correct
10 Correct 18 ms 23808 KB Output is correct
11 Correct 18 ms 23808 KB Output is correct
12 Correct 18 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 18 ms 23808 KB Output is correct
16 Correct 18 ms 23808 KB Output is correct
17 Correct 18 ms 23808 KB Output is correct
18 Correct 19 ms 23808 KB Output is correct
19 Correct 18 ms 23808 KB Output is correct
20 Correct 18 ms 23808 KB Output is correct
21 Correct 18 ms 23808 KB Output is correct
22 Correct 18 ms 23808 KB Output is correct
23 Correct 18 ms 23808 KB Output is correct
24 Correct 18 ms 23808 KB Output is correct
25 Correct 19 ms 23808 KB Output is correct
26 Correct 18 ms 23808 KB Output is correct
27 Correct 19 ms 23808 KB Output is correct
28 Correct 20 ms 23936 KB Output is correct
29 Correct 20 ms 23808 KB Output is correct
30 Correct 18 ms 23936 KB Output is correct
31 Correct 19 ms 23936 KB Output is correct
32 Correct 19 ms 23936 KB Output is correct
33 Correct 18 ms 23936 KB Output is correct
34 Correct 18 ms 23808 KB Output is correct
35 Correct 19 ms 23936 KB Output is correct
36 Correct 18 ms 23936 KB Output is correct
37 Correct 18 ms 23936 KB Output is correct
38 Correct 18 ms 23936 KB Output is correct
39 Correct 19 ms 23936 KB Output is correct
40 Correct 20 ms 23936 KB Output is correct
41 Correct 19 ms 23936 KB Output is correct
42 Correct 19 ms 23936 KB Output is correct
43 Correct 18 ms 23808 KB Output is correct
44 Correct 19 ms 23808 KB Output is correct
45 Correct 20 ms 23808 KB Output is correct
46 Correct 18 ms 23808 KB Output is correct
47 Correct 18 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 18 ms 23808 KB Output is correct
51 Correct 18 ms 23808 KB Output is correct
52 Correct 19 ms 23808 KB Output is correct
53 Correct 18 ms 23808 KB Output is correct
54 Correct 18 ms 23808 KB Output is correct
55 Correct 19 ms 23808 KB Output is correct
56 Correct 18 ms 23808 KB Output is correct
57 Correct 18 ms 23936 KB Output is correct
58 Correct 18 ms 23808 KB Output is correct
59 Correct 19 ms 23808 KB Output is correct
60 Correct 19 ms 23808 KB Output is correct
61 Correct 18 ms 23808 KB Output is correct
62 Correct 18 ms 23808 KB Output is correct
63 Correct 18 ms 23808 KB Output is correct
64 Correct 18 ms 23808 KB Output is correct
65 Correct 18 ms 23808 KB Output is correct
66 Correct 18 ms 23808 KB Output is correct
67 Correct 18 ms 23808 KB Output is correct
68 Correct 45 ms 29560 KB Output is correct
69 Correct 71 ms 35192 KB Output is correct
70 Correct 18 ms 23808 KB Output is correct
71 Correct 99 ms 40824 KB Output is correct
72 Correct 130 ms 46712 KB Output is correct
73 Correct 160 ms 52344 KB Output is correct
74 Correct 174 ms 57952 KB Output is correct
75 Correct 203 ms 63524 KB Output is correct
76 Correct 232 ms 69240 KB Output is correct
77 Correct 260 ms 75040 KB Output is correct
78 Correct 286 ms 80648 KB Output is correct
79 Correct 312 ms 86264 KB Output is correct
80 Correct 334 ms 91896 KB Output is correct
81 Correct 18 ms 23808 KB Output is correct
82 Correct 367 ms 98040 KB Output is correct
83 Correct 388 ms 103288 KB Output is correct
84 Correct 415 ms 109048 KB Output is correct
85 Correct 441 ms 114684 KB Output is correct
86 Correct 473 ms 120436 KB Output is correct
87 Correct 506 ms 125944 KB Output is correct
88 Correct 532 ms 131680 KB Output is correct
89 Correct 566 ms 137336 KB Output is correct
90 Correct 18 ms 23808 KB Output is correct
91 Correct 18 ms 23808 KB Output is correct
92 Correct 18 ms 23808 KB Output is correct
93 Correct 18 ms 23808 KB Output is correct
94 Correct 18 ms 23808 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 19 ms 23808 KB Output is correct
2 Correct 18 ms 23808 KB Output is correct
3 Correct 18 ms 23808 KB Output is correct
4 Correct 19 ms 23808 KB Output is correct
5 Correct 18 ms 23808 KB Output is correct
6 Correct 19 ms 23808 KB Output is correct
7 Correct 18 ms 23808 KB Output is correct
8 Correct 19 ms 23808 KB Output is correct
9 Correct 18 ms 23808 KB Output is correct
10 Correct 18 ms 23808 KB Output is correct
11 Correct 18 ms 23808 KB Output is correct
12 Correct 18 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 18 ms 23808 KB Output is correct
16 Correct 18 ms 23808 KB Output is correct
17 Correct 18 ms 23808 KB Output is correct
18 Correct 19 ms 23808 KB Output is correct
19 Correct 18 ms 23808 KB Output is correct
20 Correct 18 ms 23808 KB Output is correct
21 Correct 18 ms 23808 KB Output is correct
22 Correct 18 ms 23808 KB Output is correct
23 Correct 18 ms 23808 KB Output is correct
24 Correct 18 ms 23808 KB Output is correct
25 Correct 19 ms 23808 KB Output is correct
26 Correct 18 ms 23808 KB Output is correct
27 Correct 19 ms 23808 KB Output is correct
28 Correct 20 ms 23936 KB Output is correct
29 Correct 20 ms 23808 KB Output is correct
30 Correct 18 ms 23936 KB Output is correct
31 Correct 19 ms 23936 KB Output is correct
32 Correct 19 ms 23936 KB Output is correct
33 Correct 18 ms 23936 KB Output is correct
34 Correct 18 ms 23808 KB Output is correct
35 Correct 19 ms 23936 KB Output is correct
36 Correct 18 ms 23936 KB Output is correct
37 Correct 18 ms 23936 KB Output is correct
38 Correct 18 ms 23936 KB Output is correct
39 Correct 19 ms 23936 KB Output is correct
40 Correct 20 ms 23936 KB Output is correct
41 Correct 19 ms 23936 KB Output is correct
42 Correct 19 ms 23936 KB Output is correct
43 Correct 18 ms 23808 KB Output is correct
44 Correct 19 ms 23808 KB Output is correct
45 Correct 20 ms 23808 KB Output is correct
46 Correct 18 ms 23808 KB Output is correct
47 Correct 18 ms 23808 KB Output is correct
48 Correct 18 ms 23808 KB Output is correct
49 Incorrect 18 ms 23808 KB Output isn't correct
50 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 19 ms 23808 KB Output is correct
2 Correct 18 ms 23808 KB Output is correct
3 Correct 18 ms 23808 KB Output is correct
4 Correct 19 ms 23808 KB Output is correct
5 Correct 18 ms 23808 KB Output is correct
6 Correct 19 ms 23808 KB Output is correct
7 Correct 18 ms 23808 KB Output is correct
8 Correct 19 ms 23808 KB Output is correct
9 Correct 18 ms 23808 KB Output is correct
10 Correct 18 ms 23808 KB Output is correct
11 Correct 18 ms 23808 KB Output is correct
12 Correct 18 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 18 ms 23808 KB Output is correct
16 Correct 18 ms 23808 KB Output is correct
17 Correct 18 ms 23808 KB Output is correct
18 Correct 19 ms 23808 KB Output is correct
19 Correct 18 ms 23808 KB Output is correct
20 Correct 18 ms 23808 KB Output is correct
21 Correct 18 ms 23808 KB Output is correct
22 Correct 18 ms 23808 KB Output is correct
23 Correct 18 ms 23808 KB Output is correct
24 Correct 18 ms 23808 KB Output is correct
25 Correct 19 ms 23808 KB Output is correct
26 Correct 18 ms 23808 KB Output is correct
27 Correct 19 ms 23808 KB Output is correct
28 Correct 20 ms 23936 KB Output is correct
29 Correct 20 ms 23808 KB Output is correct
30 Correct 18 ms 23936 KB Output is correct
31 Correct 19 ms 23936 KB Output is correct
32 Correct 19 ms 23936 KB Output is correct
33 Correct 18 ms 23936 KB Output is correct
34 Correct 18 ms 23808 KB Output is correct
35 Correct 19 ms 23936 KB Output is correct
36 Correct 18 ms 23936 KB Output is correct
37 Correct 18 ms 23936 KB Output is correct
38 Correct 18 ms 23936 KB Output is correct
39 Correct 19 ms 23936 KB Output is correct
40 Correct 20 ms 23936 KB Output is correct
41 Correct 19 ms 23936 KB Output is correct
42 Correct 19 ms 23936 KB Output is correct
43 Correct 18 ms 23808 KB Output is correct
44 Correct 19 ms 23808 KB Output is correct
45 Correct 20 ms 23808 KB Output is correct
46 Correct 18 ms 23808 KB Output is correct
47 Correct 18 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 18 ms 23808 KB Output is correct
51 Correct 18 ms 23808 KB Output is correct
52 Correct 19 ms 23808 KB Output is correct
53 Correct 18 ms 23808 KB Output is correct
54 Correct 18 ms 23808 KB Output is correct
55 Correct 19 ms 23808 KB Output is correct
56 Correct 18 ms 23808 KB Output is correct
57 Correct 18 ms 23936 KB Output is correct
58 Correct 18 ms 23808 KB Output is correct
59 Correct 19 ms 23808 KB Output is correct
60 Correct 19 ms 23808 KB Output is correct
61 Correct 18 ms 23808 KB Output is correct
62 Correct 18 ms 23808 KB Output is correct
63 Correct 18 ms 23808 KB Output is correct
64 Correct 18 ms 23808 KB Output is correct
65 Correct 18 ms 23808 KB Output is correct
66 Correct 18 ms 23808 KB Output is correct
67 Correct 18 ms 23808 KB Output is correct
68 Correct 45 ms 29560 KB Output is correct
69 Correct 71 ms 35192 KB Output is correct
70 Correct 18 ms 23808 KB Output is correct
71 Correct 99 ms 40824 KB Output is correct
72 Correct 130 ms 46712 KB Output is correct
73 Correct 160 ms 52344 KB Output is correct
74 Correct 174 ms 57952 KB Output is correct
75 Correct 203 ms 63524 KB Output is correct
76 Correct 232 ms 69240 KB Output is correct
77 Correct 260 ms 75040 KB Output is correct
78 Correct 286 ms 80648 KB Output is correct
79 Correct 312 ms 86264 KB Output is correct
80 Correct 334 ms 91896 KB Output is correct
81 Correct 18 ms 23808 KB Output is correct
82 Correct 367 ms 98040 KB Output is correct
83 Correct 388 ms 103288 KB Output is correct
84 Correct 415 ms 109048 KB Output is correct
85 Correct 441 ms 114684 KB Output is correct
86 Correct 473 ms 120436 KB Output is correct
87 Correct 506 ms 125944 KB Output is correct
88 Correct 532 ms 131680 KB Output is correct
89 Correct 566 ms 137336 KB Output is correct
90 Correct 18 ms 23808 KB Output is correct
91 Correct 18 ms 23808 KB Output is correct
92 Correct 18 ms 23808 KB Output is correct
93 Correct 18 ms 23808 KB Output is correct
94 Correct 18 ms 23808 KB Output is correct
95 Correct 18 ms 23808 KB Output is correct
96 Incorrect 18 ms 23808 KB Output isn't correct
97 Halted 0 ms 0 KB -