Submission #427348

# Submission time Handle Problem Language Result Execution time Memory
427348 2021-06-14T14:28:26 Z cpp219 Traffic (IOI10_traffic) C++14
50 / 100
478 ms 262148 KB
#pragma GCC optimization "O2"
#pragma GCC optimization "unroll-loop"
#pragma GCC target ("avx2")

#include <bits/stdc++.h>
#define ll int
#define ld long double
#define fs first
#define sc second
using namespace std;
const ll N = 2e6 + 9;
const ll inf = 1e9 + 7;
const ll Log2 = 20;
typedef pair<ll,ll> LL;
vector<ll> g[N];
ll n,a[N],mn = inf,chosen,child[N],InitChild[N],sum;
set<LL> s[N];

void DFSinit(ll u,ll p){
    child[u] = a[u];
    for (auto i : g[u]){
        if (i == p) continue;
        DFSinit(i,u); child[u] += child[i];
        s[u].insert({child[i],i});
    }
    InitChild[u] = child[u];
}

void DFS(ll u,ll p){
    if (!s[u].empty()){
        LL now = *s[u].rbegin(),rm = {sum - child[u],-1};
        now = max(now,rm);
        if (now.fs < mn) mn = now.fs,chosen = u;
    }
    for (auto i : g[u]){
        if (i == p) continue;
        s[u].erase({child[i],i}); s[i].insert({sum - child[i],u});
        //cout<<child[i]<<" "<<i; exit(0);
        child[u] = sum - child[i]; child[i] = sum;
        DFS(i,u);
    }
    if (p >= 0){
        child[u] = InitChild[u];
        s[p].insert({child[u],u}); s[u].erase({child[p],p});
        child[p] = InitChild[p];
    }
}

ll LocateCentre(ll sz,ll P[],ll X[],ll Y[]){
    n = sz;
    for (ll i = 0;i < n;i++) a[i] = P[i],sum += a[i];
    for (ll i = 0;i < n - 1;i++){
        g[X[i]].push_back(Y[i]); g[Y[i]].push_back(X[i]);
    }
    DFSinit(0,-1); DFS(0,-1);
    return chosen;
}
/*
ll sz,X[N],Y[N],P[N];

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    #define task "test"
    if (fopen(task".inp", "r")){
        freopen(task".inp", "r", stdin);
        //freopen(task".out", "w", stdout);
    }
    cin>>sz;
    for (ll i = 0;i < sz;i++) cin>>P[i];
    for (ll i = 0;i < sz - 1;i++) cin>>X[i]>>Y[i];
    cout<<LocateCentre(sz,P,X,Y);
}
*/

Compilation message

traffic.cpp:1: warning: ignoring '#pragma GCC optimization' [-Wunknown-pragmas]
    1 | #pragma GCC optimization "O2"
      | 
traffic.cpp:2: warning: ignoring '#pragma GCC optimization' [-Wunknown-pragmas]
    2 | #pragma GCC optimization "unroll-loop"
      |
# Verdict Execution time Memory Grader output
1 Correct 97 ms 141192 KB Output is correct
2 Correct 90 ms 141208 KB Output is correct
3 Correct 88 ms 141124 KB Output is correct
4 Correct 89 ms 141132 KB Output is correct
5 Correct 88 ms 141196 KB Output is correct
6 Correct 95 ms 141172 KB Output is correct
7 Correct 88 ms 141160 KB Output is correct
8 Correct 90 ms 141128 KB Output is correct
9 Correct 94 ms 141216 KB Output is correct
10 Correct 91 ms 141124 KB Output is correct
11 Correct 94 ms 141224 KB Output is correct
12 Correct 94 ms 141228 KB Output is correct
13 Correct 92 ms 141224 KB Output is correct
14 Correct 91 ms 141124 KB Output is correct
15 Correct 97 ms 141124 KB Output is correct
16 Correct 83 ms 141228 KB Output is correct
17 Correct 87 ms 141176 KB Output is correct
18 Correct 82 ms 141168 KB Output is correct
19 Correct 93 ms 141140 KB Output is correct
20 Correct 80 ms 141224 KB Output is correct
21 Correct 85 ms 141184 KB Output is correct
22 Correct 102 ms 141196 KB Output is correct
23 Correct 100 ms 141208 KB Output is correct
24 Correct 85 ms 141252 KB Output is correct
25 Correct 92 ms 141232 KB Output is correct
26 Correct 93 ms 141236 KB Output is correct
27 Correct 92 ms 141284 KB Output is correct
28 Correct 100 ms 141208 KB Output is correct
29 Correct 88 ms 141256 KB Output is correct
30 Correct 101 ms 141452 KB Output is correct
31 Correct 87 ms 141340 KB Output is correct
32 Correct 93 ms 141296 KB Output is correct
33 Correct 94 ms 141328 KB Output is correct
34 Correct 96 ms 141124 KB Output is correct
35 Correct 91 ms 141300 KB Output is correct
36 Correct 94 ms 141348 KB Output is correct
37 Correct 86 ms 141364 KB Output is correct
38 Correct 93 ms 141408 KB Output is correct
39 Correct 100 ms 141340 KB Output is correct
40 Correct 86 ms 141332 KB Output is correct
41 Correct 93 ms 141440 KB Output is correct
42 Correct 91 ms 141364 KB Output is correct
43 Correct 102 ms 141220 KB Output is correct
44 Correct 89 ms 141180 KB Output is correct
45 Correct 88 ms 141296 KB Output is correct
46 Correct 95 ms 141128 KB Output is correct
47 Correct 89 ms 141188 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 97 ms 141192 KB Output is correct
2 Correct 90 ms 141208 KB Output is correct
3 Correct 88 ms 141124 KB Output is correct
4 Correct 89 ms 141132 KB Output is correct
5 Correct 88 ms 141196 KB Output is correct
6 Correct 95 ms 141172 KB Output is correct
7 Correct 88 ms 141160 KB Output is correct
8 Correct 90 ms 141128 KB Output is correct
9 Correct 94 ms 141216 KB Output is correct
10 Correct 91 ms 141124 KB Output is correct
11 Correct 94 ms 141224 KB Output is correct
12 Correct 94 ms 141228 KB Output is correct
13 Correct 92 ms 141224 KB Output is correct
14 Correct 91 ms 141124 KB Output is correct
15 Correct 97 ms 141124 KB Output is correct
16 Correct 83 ms 141228 KB Output is correct
17 Correct 87 ms 141176 KB Output is correct
18 Correct 82 ms 141168 KB Output is correct
19 Correct 93 ms 141140 KB Output is correct
20 Correct 80 ms 141224 KB Output is correct
21 Correct 85 ms 141184 KB Output is correct
22 Correct 102 ms 141196 KB Output is correct
23 Correct 100 ms 141208 KB Output is correct
24 Correct 85 ms 141252 KB Output is correct
25 Correct 92 ms 141232 KB Output is correct
26 Correct 93 ms 141236 KB Output is correct
27 Correct 92 ms 141284 KB Output is correct
28 Correct 100 ms 141208 KB Output is correct
29 Correct 88 ms 141256 KB Output is correct
30 Correct 101 ms 141452 KB Output is correct
31 Correct 87 ms 141340 KB Output is correct
32 Correct 93 ms 141296 KB Output is correct
33 Correct 94 ms 141328 KB Output is correct
34 Correct 96 ms 141124 KB Output is correct
35 Correct 91 ms 141300 KB Output is correct
36 Correct 94 ms 141348 KB Output is correct
37 Correct 86 ms 141364 KB Output is correct
38 Correct 93 ms 141408 KB Output is correct
39 Correct 100 ms 141340 KB Output is correct
40 Correct 86 ms 141332 KB Output is correct
41 Correct 93 ms 141440 KB Output is correct
42 Correct 91 ms 141364 KB Output is correct
43 Correct 102 ms 141220 KB Output is correct
44 Correct 89 ms 141180 KB Output is correct
45 Correct 88 ms 141296 KB Output is correct
46 Correct 95 ms 141128 KB Output is correct
47 Correct 89 ms 141188 KB Output is correct
48 Correct 94 ms 141292 KB Output is correct
49 Correct 96 ms 141220 KB Output is correct
50 Correct 92 ms 141124 KB Output is correct
51 Correct 103 ms 141196 KB Output is correct
52 Correct 92 ms 141148 KB Output is correct
53 Correct 91 ms 141124 KB Output is correct
54 Correct 96 ms 141224 KB Output is correct
55 Correct 91 ms 141176 KB Output is correct
56 Correct 102 ms 141108 KB Output is correct
57 Correct 89 ms 141132 KB Output is correct
58 Correct 102 ms 141200 KB Output is correct
59 Correct 94 ms 141152 KB Output is correct
60 Correct 81 ms 141220 KB Output is correct
61 Correct 83 ms 141224 KB Output is correct
62 Correct 92 ms 141140 KB Output is correct
63 Correct 91 ms 141124 KB Output is correct
64 Correct 92 ms 141228 KB Output is correct
65 Correct 89 ms 141200 KB Output is correct
66 Correct 92 ms 141108 KB Output is correct
67 Correct 86 ms 141192 KB Output is correct
68 Correct 124 ms 152516 KB Output is correct
69 Correct 155 ms 163800 KB Output is correct
70 Correct 91 ms 141220 KB Output is correct
71 Correct 227 ms 175148 KB Output is correct
72 Correct 270 ms 186496 KB Output is correct
73 Correct 266 ms 197972 KB Output is correct
74 Correct 347 ms 209528 KB Output is correct
75 Correct 371 ms 220656 KB Output is correct
76 Correct 366 ms 231908 KB Output is correct
77 Correct 405 ms 243472 KB Output is correct
78 Correct 478 ms 254676 KB Output is correct
79 Runtime error 455 ms 262148 KB Execution killed with signal 9
80 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 97 ms 141192 KB Output is correct
2 Correct 90 ms 141208 KB Output is correct
3 Correct 88 ms 141124 KB Output is correct
4 Correct 89 ms 141132 KB Output is correct
5 Correct 88 ms 141196 KB Output is correct
6 Correct 95 ms 141172 KB Output is correct
7 Correct 88 ms 141160 KB Output is correct
8 Correct 90 ms 141128 KB Output is correct
9 Correct 94 ms 141216 KB Output is correct
10 Correct 91 ms 141124 KB Output is correct
11 Correct 94 ms 141224 KB Output is correct
12 Correct 94 ms 141228 KB Output is correct
13 Correct 92 ms 141224 KB Output is correct
14 Correct 91 ms 141124 KB Output is correct
15 Correct 97 ms 141124 KB Output is correct
16 Correct 83 ms 141228 KB Output is correct
17 Correct 87 ms 141176 KB Output is correct
18 Correct 82 ms 141168 KB Output is correct
19 Correct 93 ms 141140 KB Output is correct
20 Correct 80 ms 141224 KB Output is correct
21 Correct 85 ms 141184 KB Output is correct
22 Correct 102 ms 141196 KB Output is correct
23 Correct 100 ms 141208 KB Output is correct
24 Correct 85 ms 141252 KB Output is correct
25 Correct 92 ms 141232 KB Output is correct
26 Correct 93 ms 141236 KB Output is correct
27 Correct 92 ms 141284 KB Output is correct
28 Correct 100 ms 141208 KB Output is correct
29 Correct 88 ms 141256 KB Output is correct
30 Correct 101 ms 141452 KB Output is correct
31 Correct 87 ms 141340 KB Output is correct
32 Correct 93 ms 141296 KB Output is correct
33 Correct 94 ms 141328 KB Output is correct
34 Correct 96 ms 141124 KB Output is correct
35 Correct 91 ms 141300 KB Output is correct
36 Correct 94 ms 141348 KB Output is correct
37 Correct 86 ms 141364 KB Output is correct
38 Correct 93 ms 141408 KB Output is correct
39 Correct 100 ms 141340 KB Output is correct
40 Correct 86 ms 141332 KB Output is correct
41 Correct 93 ms 141440 KB Output is correct
42 Correct 91 ms 141364 KB Output is correct
43 Correct 102 ms 141220 KB Output is correct
44 Correct 89 ms 141180 KB Output is correct
45 Correct 88 ms 141296 KB Output is correct
46 Correct 95 ms 141128 KB Output is correct
47 Correct 89 ms 141188 KB Output is correct
48 Correct 93 ms 141128 KB Output is correct
49 Correct 88 ms 141220 KB Output is correct
50 Correct 99 ms 141136 KB Output is correct
51 Correct 97 ms 141224 KB Output is correct
52 Correct 94 ms 141240 KB Output is correct
53 Correct 96 ms 141172 KB Output is correct
54 Correct 101 ms 141240 KB Output is correct
55 Correct 93 ms 141120 KB Output is correct
56 Correct 87 ms 141216 KB Output is correct
57 Correct 92 ms 141208 KB Output is correct
58 Correct 95 ms 141176 KB Output is correct
59 Correct 93 ms 141224 KB Output is correct
60 Correct 98 ms 141116 KB Output is correct
61 Correct 88 ms 141204 KB Output is correct
62 Correct 84 ms 141212 KB Output is correct
63 Correct 83 ms 141228 KB Output is correct
64 Correct 95 ms 141140 KB Output is correct
65 Correct 96 ms 141224 KB Output is correct
66 Correct 86 ms 141184 KB Output is correct
67 Correct 100 ms 141124 KB Output is correct
68 Correct 87 ms 141188 KB Output is correct
69 Correct 82 ms 141148 KB Output is correct
70 Correct 88 ms 141220 KB Output is correct
71 Correct 103 ms 141124 KB Output is correct
72 Correct 102 ms 141228 KB Output is correct
73 Correct 103 ms 141124 KB Output is correct
74 Correct 103 ms 141180 KB Output is correct
75 Correct 93 ms 141312 KB Output is correct
76 Correct 106 ms 141172 KB Output is correct
77 Correct 101 ms 141256 KB Output is correct
78 Correct 100 ms 141208 KB Output is correct
79 Correct 91 ms 141164 KB Output is correct
80 Correct 92 ms 141160 KB Output is correct
81 Correct 91 ms 141120 KB Output is correct
82 Correct 98 ms 141188 KB Output is correct
83 Correct 102 ms 141252 KB Output is correct
84 Correct 89 ms 141252 KB Output is correct
85 Correct 88 ms 141208 KB Output is correct
86 Correct 95 ms 141252 KB Output is correct
87 Correct 89 ms 141252 KB Output is correct
88 Correct 96 ms 141252 KB Output is correct
89 Correct 94 ms 141316 KB Output is correct
90 Correct 89 ms 141248 KB Output is correct
91 Correct 90 ms 141224 KB Output is correct
92 Correct 89 ms 141140 KB Output is correct
93 Correct 97 ms 141324 KB Output is correct
94 Correct 94 ms 141276 KB Output is correct
95 Correct 89 ms 141380 KB Output is correct
96 Correct 87 ms 141188 KB Output is correct
97 Correct 92 ms 141200 KB Output is correct
98 Correct 90 ms 141240 KB Output is correct
99 Correct 98 ms 141224 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 97 ms 141192 KB Output is correct
2 Correct 90 ms 141208 KB Output is correct
3 Correct 88 ms 141124 KB Output is correct
4 Correct 89 ms 141132 KB Output is correct
5 Correct 88 ms 141196 KB Output is correct
6 Correct 95 ms 141172 KB Output is correct
7 Correct 88 ms 141160 KB Output is correct
8 Correct 90 ms 141128 KB Output is correct
9 Correct 94 ms 141216 KB Output is correct
10 Correct 91 ms 141124 KB Output is correct
11 Correct 94 ms 141224 KB Output is correct
12 Correct 94 ms 141228 KB Output is correct
13 Correct 92 ms 141224 KB Output is correct
14 Correct 91 ms 141124 KB Output is correct
15 Correct 97 ms 141124 KB Output is correct
16 Correct 83 ms 141228 KB Output is correct
17 Correct 87 ms 141176 KB Output is correct
18 Correct 82 ms 141168 KB Output is correct
19 Correct 93 ms 141140 KB Output is correct
20 Correct 80 ms 141224 KB Output is correct
21 Correct 85 ms 141184 KB Output is correct
22 Correct 102 ms 141196 KB Output is correct
23 Correct 100 ms 141208 KB Output is correct
24 Correct 85 ms 141252 KB Output is correct
25 Correct 92 ms 141232 KB Output is correct
26 Correct 93 ms 141236 KB Output is correct
27 Correct 92 ms 141284 KB Output is correct
28 Correct 100 ms 141208 KB Output is correct
29 Correct 88 ms 141256 KB Output is correct
30 Correct 101 ms 141452 KB Output is correct
31 Correct 87 ms 141340 KB Output is correct
32 Correct 93 ms 141296 KB Output is correct
33 Correct 94 ms 141328 KB Output is correct
34 Correct 96 ms 141124 KB Output is correct
35 Correct 91 ms 141300 KB Output is correct
36 Correct 94 ms 141348 KB Output is correct
37 Correct 86 ms 141364 KB Output is correct
38 Correct 93 ms 141408 KB Output is correct
39 Correct 100 ms 141340 KB Output is correct
40 Correct 86 ms 141332 KB Output is correct
41 Correct 93 ms 141440 KB Output is correct
42 Correct 91 ms 141364 KB Output is correct
43 Correct 102 ms 141220 KB Output is correct
44 Correct 89 ms 141180 KB Output is correct
45 Correct 88 ms 141296 KB Output is correct
46 Correct 95 ms 141128 KB Output is correct
47 Correct 89 ms 141188 KB Output is correct
48 Correct 94 ms 141292 KB Output is correct
49 Correct 96 ms 141220 KB Output is correct
50 Correct 92 ms 141124 KB Output is correct
51 Correct 103 ms 141196 KB Output is correct
52 Correct 92 ms 141148 KB Output is correct
53 Correct 91 ms 141124 KB Output is correct
54 Correct 96 ms 141224 KB Output is correct
55 Correct 91 ms 141176 KB Output is correct
56 Correct 102 ms 141108 KB Output is correct
57 Correct 89 ms 141132 KB Output is correct
58 Correct 102 ms 141200 KB Output is correct
59 Correct 94 ms 141152 KB Output is correct
60 Correct 81 ms 141220 KB Output is correct
61 Correct 83 ms 141224 KB Output is correct
62 Correct 92 ms 141140 KB Output is correct
63 Correct 91 ms 141124 KB Output is correct
64 Correct 92 ms 141228 KB Output is correct
65 Correct 89 ms 141200 KB Output is correct
66 Correct 92 ms 141108 KB Output is correct
67 Correct 86 ms 141192 KB Output is correct
68 Correct 124 ms 152516 KB Output is correct
69 Correct 155 ms 163800 KB Output is correct
70 Correct 91 ms 141220 KB Output is correct
71 Correct 227 ms 175148 KB Output is correct
72 Correct 270 ms 186496 KB Output is correct
73 Correct 266 ms 197972 KB Output is correct
74 Correct 347 ms 209528 KB Output is correct
75 Correct 371 ms 220656 KB Output is correct
76 Correct 366 ms 231908 KB Output is correct
77 Correct 405 ms 243472 KB Output is correct
78 Correct 478 ms 254676 KB Output is correct
79 Runtime error 455 ms 262148 KB Execution killed with signal 9
80 Halted 0 ms 0 KB -