답안 #414869

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
414869 2021-05-31T09:48:49 Z JediMaster11 Traffic (IOI10_traffic) C++17
50 / 100
5000 ms 27288 KB
#include <bits/stdc++.h>
#include "traffic.h"
using namespace std;
 

#define ll long long
#define uint unsigned int
#define ull unsigned long long
#define endl "\n"
#define elif else if
#define fo(i, a, b) for (int i = a; i < (int)b; i++)
#define rfo(i, a, b) for (int i = a - 1; i >= b; i--)
#define v(i) vector<i>
#define vll vector<long long>
#define vstr vector<string>
#define pairll pair<long long, long long>
#define vpairll vector<pair<long long, long long>>
#define print(x) cout << x << "\n"

#define pushall(x, n)                   \
    x.resize(n);                        \
    for (int zz = 0; zz < (int)n; zz++) \
    {                                   \
        cin >> x[zz];                   \
    }




const int MAX_N = 1e6 + 3e2;
vector<int> adj[MAX_N];
 
int dfs(int u, int p, int P[]) {
    int ans = P[u];
    for(int to : adj[u]) {
        if(to == p) continue;
        ans += dfs(to, u, P);
    }
    return ans;
}
 
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]);
    }
 
    int ans = 2147483647, ret = -1;
    for(int i = 0; i < N; i++) {
        int max_traffic = -2147483648;
        for(int to : adj[i]) {
            max_traffic = max(max_traffic, dfs(to, i, P));
        }
        if(max_traffic < ans) {
            ans = max_traffic;
            ret = i;
        }
    }
    return ret;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 15 ms 23756 KB Output is correct
2 Correct 15 ms 23708 KB Output is correct
3 Correct 15 ms 23764 KB Output is correct
4 Correct 15 ms 23796 KB Output is correct
5 Correct 15 ms 23756 KB Output is correct
6 Correct 15 ms 23800 KB Output is correct
7 Correct 18 ms 23756 KB Output is correct
8 Correct 18 ms 23756 KB Output is correct
9 Correct 15 ms 23732 KB Output is correct
10 Correct 15 ms 23732 KB Output is correct
11 Correct 15 ms 23756 KB Output is correct
12 Correct 15 ms 23756 KB Output is correct
13 Correct 16 ms 23788 KB Output is correct
14 Correct 16 ms 23828 KB Output is correct
15 Correct 15 ms 23720 KB Output is correct
16 Correct 15 ms 23756 KB Output is correct
17 Correct 16 ms 23720 KB Output is correct
18 Correct 15 ms 23756 KB Output is correct
19 Correct 15 ms 23756 KB Output is correct
20 Correct 16 ms 23796 KB Output is correct
21 Correct 17 ms 23752 KB Output is correct
22 Correct 15 ms 23804 KB Output is correct
23 Correct 15 ms 23756 KB Output is correct
24 Correct 17 ms 23756 KB Output is correct
25 Correct 18 ms 23756 KB Output is correct
26 Correct 16 ms 23812 KB Output is correct
27 Correct 17 ms 23776 KB Output is correct
28 Correct 17 ms 23756 KB Output is correct
29 Correct 18 ms 23824 KB Output is correct
30 Correct 19 ms 23756 KB Output is correct
31 Correct 19 ms 23816 KB Output is correct
32 Correct 19 ms 23836 KB Output is correct
33 Correct 20 ms 23788 KB Output is correct
34 Correct 15 ms 23748 KB Output is correct
35 Correct 20 ms 23756 KB Output is correct
36 Correct 22 ms 23824 KB Output is correct
37 Correct 22 ms 23824 KB Output is correct
38 Correct 22 ms 23788 KB Output is correct
39 Correct 24 ms 23756 KB Output is correct
40 Correct 24 ms 23860 KB Output is correct
41 Correct 25 ms 23756 KB Output is correct
42 Correct 26 ms 23884 KB Output is correct
43 Correct 16 ms 23756 KB Output is correct
44 Correct 15 ms 23756 KB Output is correct
45 Correct 15 ms 23756 KB Output is correct
46 Correct 15 ms 23772 KB Output is correct
47 Correct 15 ms 23756 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 15 ms 23756 KB Output is correct
2 Correct 15 ms 23708 KB Output is correct
3 Correct 15 ms 23764 KB Output is correct
4 Correct 15 ms 23796 KB Output is correct
5 Correct 15 ms 23756 KB Output is correct
6 Correct 15 ms 23800 KB Output is correct
7 Correct 18 ms 23756 KB Output is correct
8 Correct 18 ms 23756 KB Output is correct
9 Correct 15 ms 23732 KB Output is correct
10 Correct 15 ms 23732 KB Output is correct
11 Correct 15 ms 23756 KB Output is correct
12 Correct 15 ms 23756 KB Output is correct
13 Correct 16 ms 23788 KB Output is correct
14 Correct 16 ms 23828 KB Output is correct
15 Correct 15 ms 23720 KB Output is correct
16 Correct 15 ms 23756 KB Output is correct
17 Correct 16 ms 23720 KB Output is correct
18 Correct 15 ms 23756 KB Output is correct
19 Correct 15 ms 23756 KB Output is correct
20 Correct 16 ms 23796 KB Output is correct
21 Correct 17 ms 23752 KB Output is correct
22 Correct 15 ms 23804 KB Output is correct
23 Correct 15 ms 23756 KB Output is correct
24 Correct 17 ms 23756 KB Output is correct
25 Correct 18 ms 23756 KB Output is correct
26 Correct 16 ms 23812 KB Output is correct
27 Correct 17 ms 23776 KB Output is correct
28 Correct 17 ms 23756 KB Output is correct
29 Correct 18 ms 23824 KB Output is correct
30 Correct 19 ms 23756 KB Output is correct
31 Correct 19 ms 23816 KB Output is correct
32 Correct 19 ms 23836 KB Output is correct
33 Correct 20 ms 23788 KB Output is correct
34 Correct 15 ms 23748 KB Output is correct
35 Correct 20 ms 23756 KB Output is correct
36 Correct 22 ms 23824 KB Output is correct
37 Correct 22 ms 23824 KB Output is correct
38 Correct 22 ms 23788 KB Output is correct
39 Correct 24 ms 23756 KB Output is correct
40 Correct 24 ms 23860 KB Output is correct
41 Correct 25 ms 23756 KB Output is correct
42 Correct 26 ms 23884 KB Output is correct
43 Correct 16 ms 23756 KB Output is correct
44 Correct 15 ms 23756 KB Output is correct
45 Correct 15 ms 23756 KB Output is correct
46 Correct 15 ms 23772 KB Output is correct
47 Correct 15 ms 23756 KB Output is correct
48 Correct 17 ms 23804 KB Output is correct
49 Correct 16 ms 23764 KB Output is correct
50 Correct 15 ms 23756 KB Output is correct
51 Correct 14 ms 23756 KB Output is correct
52 Correct 16 ms 23812 KB Output is correct
53 Correct 15 ms 23804 KB Output is correct
54 Correct 15 ms 23796 KB Output is correct
55 Correct 15 ms 23772 KB Output is correct
56 Correct 18 ms 23756 KB Output is correct
57 Correct 15 ms 23756 KB Output is correct
58 Correct 15 ms 23776 KB Output is correct
59 Correct 15 ms 23756 KB Output is correct
60 Correct 15 ms 23732 KB Output is correct
61 Correct 15 ms 23756 KB Output is correct
62 Correct 15 ms 23804 KB Output is correct
63 Correct 15 ms 23756 KB Output is correct
64 Correct 15 ms 23780 KB Output is correct
65 Correct 16 ms 23808 KB Output is correct
66 Correct 15 ms 23776 KB Output is correct
67 Correct 14 ms 23756 KB Output is correct
68 Execution timed out 5056 ms 27288 KB Time limit exceeded
69 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 15 ms 23756 KB Output is correct
2 Correct 15 ms 23708 KB Output is correct
3 Correct 15 ms 23764 KB Output is correct
4 Correct 15 ms 23796 KB Output is correct
5 Correct 15 ms 23756 KB Output is correct
6 Correct 15 ms 23800 KB Output is correct
7 Correct 18 ms 23756 KB Output is correct
8 Correct 18 ms 23756 KB Output is correct
9 Correct 15 ms 23732 KB Output is correct
10 Correct 15 ms 23732 KB Output is correct
11 Correct 15 ms 23756 KB Output is correct
12 Correct 15 ms 23756 KB Output is correct
13 Correct 16 ms 23788 KB Output is correct
14 Correct 16 ms 23828 KB Output is correct
15 Correct 15 ms 23720 KB Output is correct
16 Correct 15 ms 23756 KB Output is correct
17 Correct 16 ms 23720 KB Output is correct
18 Correct 15 ms 23756 KB Output is correct
19 Correct 15 ms 23756 KB Output is correct
20 Correct 16 ms 23796 KB Output is correct
21 Correct 17 ms 23752 KB Output is correct
22 Correct 15 ms 23804 KB Output is correct
23 Correct 15 ms 23756 KB Output is correct
24 Correct 17 ms 23756 KB Output is correct
25 Correct 18 ms 23756 KB Output is correct
26 Correct 16 ms 23812 KB Output is correct
27 Correct 17 ms 23776 KB Output is correct
28 Correct 17 ms 23756 KB Output is correct
29 Correct 18 ms 23824 KB Output is correct
30 Correct 19 ms 23756 KB Output is correct
31 Correct 19 ms 23816 KB Output is correct
32 Correct 19 ms 23836 KB Output is correct
33 Correct 20 ms 23788 KB Output is correct
34 Correct 15 ms 23748 KB Output is correct
35 Correct 20 ms 23756 KB Output is correct
36 Correct 22 ms 23824 KB Output is correct
37 Correct 22 ms 23824 KB Output is correct
38 Correct 22 ms 23788 KB Output is correct
39 Correct 24 ms 23756 KB Output is correct
40 Correct 24 ms 23860 KB Output is correct
41 Correct 25 ms 23756 KB Output is correct
42 Correct 26 ms 23884 KB Output is correct
43 Correct 16 ms 23756 KB Output is correct
44 Correct 15 ms 23756 KB Output is correct
45 Correct 15 ms 23756 KB Output is correct
46 Correct 15 ms 23772 KB Output is correct
47 Correct 15 ms 23756 KB Output is correct
48 Correct 16 ms 23736 KB Output is correct
49 Correct 14 ms 23688 KB Output is correct
50 Correct 17 ms 23756 KB Output is correct
51 Correct 17 ms 23756 KB Output is correct
52 Correct 16 ms 23772 KB Output is correct
53 Correct 15 ms 23756 KB Output is correct
54 Correct 17 ms 23808 KB Output is correct
55 Correct 15 ms 23756 KB Output is correct
56 Correct 15 ms 23712 KB Output is correct
57 Correct 15 ms 23756 KB Output is correct
58 Correct 16 ms 23756 KB Output is correct
59 Correct 16 ms 23756 KB Output is correct
60 Correct 16 ms 23756 KB Output is correct
61 Correct 16 ms 23756 KB Output is correct
62 Correct 15 ms 23756 KB Output is correct
63 Correct 16 ms 23756 KB Output is correct
64 Correct 15 ms 23756 KB Output is correct
65 Correct 19 ms 23756 KB Output is correct
66 Correct 16 ms 23796 KB Output is correct
67 Correct 15 ms 23808 KB Output is correct
68 Correct 16 ms 23756 KB Output is correct
69 Correct 16 ms 23756 KB Output is correct
70 Correct 15 ms 23712 KB Output is correct
71 Correct 15 ms 23756 KB Output is correct
72 Correct 16 ms 23756 KB Output is correct
73 Correct 15 ms 23748 KB Output is correct
74 Correct 16 ms 23756 KB Output is correct
75 Correct 16 ms 23724 KB Output is correct
76 Correct 16 ms 23692 KB Output is correct
77 Correct 17 ms 23732 KB Output is correct
78 Correct 17 ms 23756 KB Output is correct
79 Correct 20 ms 23756 KB Output is correct
80 Correct 20 ms 23804 KB Output is correct
81 Correct 16 ms 23756 KB Output is correct
82 Correct 20 ms 23756 KB Output is correct
83 Correct 21 ms 23756 KB Output is correct
84 Correct 22 ms 23832 KB Output is correct
85 Correct 23 ms 23756 KB Output is correct
86 Correct 26 ms 23780 KB Output is correct
87 Correct 27 ms 23832 KB Output is correct
88 Correct 28 ms 23832 KB Output is correct
89 Correct 30 ms 23756 KB Output is correct
90 Correct 37 ms 23796 KB Output is correct
91 Correct 34 ms 23816 KB Output is correct
92 Correct 15 ms 23792 KB Output is correct
93 Correct 37 ms 23844 KB Output is correct
94 Correct 19 ms 23756 KB Output is correct
95 Correct 26 ms 23756 KB Output is correct
96 Correct 15 ms 23756 KB Output is correct
97 Correct 15 ms 23724 KB Output is correct
98 Correct 15 ms 23760 KB Output is correct
99 Correct 18 ms 23756 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 15 ms 23756 KB Output is correct
2 Correct 15 ms 23708 KB Output is correct
3 Correct 15 ms 23764 KB Output is correct
4 Correct 15 ms 23796 KB Output is correct
5 Correct 15 ms 23756 KB Output is correct
6 Correct 15 ms 23800 KB Output is correct
7 Correct 18 ms 23756 KB Output is correct
8 Correct 18 ms 23756 KB Output is correct
9 Correct 15 ms 23732 KB Output is correct
10 Correct 15 ms 23732 KB Output is correct
11 Correct 15 ms 23756 KB Output is correct
12 Correct 15 ms 23756 KB Output is correct
13 Correct 16 ms 23788 KB Output is correct
14 Correct 16 ms 23828 KB Output is correct
15 Correct 15 ms 23720 KB Output is correct
16 Correct 15 ms 23756 KB Output is correct
17 Correct 16 ms 23720 KB Output is correct
18 Correct 15 ms 23756 KB Output is correct
19 Correct 15 ms 23756 KB Output is correct
20 Correct 16 ms 23796 KB Output is correct
21 Correct 17 ms 23752 KB Output is correct
22 Correct 15 ms 23804 KB Output is correct
23 Correct 15 ms 23756 KB Output is correct
24 Correct 17 ms 23756 KB Output is correct
25 Correct 18 ms 23756 KB Output is correct
26 Correct 16 ms 23812 KB Output is correct
27 Correct 17 ms 23776 KB Output is correct
28 Correct 17 ms 23756 KB Output is correct
29 Correct 18 ms 23824 KB Output is correct
30 Correct 19 ms 23756 KB Output is correct
31 Correct 19 ms 23816 KB Output is correct
32 Correct 19 ms 23836 KB Output is correct
33 Correct 20 ms 23788 KB Output is correct
34 Correct 15 ms 23748 KB Output is correct
35 Correct 20 ms 23756 KB Output is correct
36 Correct 22 ms 23824 KB Output is correct
37 Correct 22 ms 23824 KB Output is correct
38 Correct 22 ms 23788 KB Output is correct
39 Correct 24 ms 23756 KB Output is correct
40 Correct 24 ms 23860 KB Output is correct
41 Correct 25 ms 23756 KB Output is correct
42 Correct 26 ms 23884 KB Output is correct
43 Correct 16 ms 23756 KB Output is correct
44 Correct 15 ms 23756 KB Output is correct
45 Correct 15 ms 23756 KB Output is correct
46 Correct 15 ms 23772 KB Output is correct
47 Correct 15 ms 23756 KB Output is correct
48 Correct 17 ms 23804 KB Output is correct
49 Correct 16 ms 23764 KB Output is correct
50 Correct 15 ms 23756 KB Output is correct
51 Correct 14 ms 23756 KB Output is correct
52 Correct 16 ms 23812 KB Output is correct
53 Correct 15 ms 23804 KB Output is correct
54 Correct 15 ms 23796 KB Output is correct
55 Correct 15 ms 23772 KB Output is correct
56 Correct 18 ms 23756 KB Output is correct
57 Correct 15 ms 23756 KB Output is correct
58 Correct 15 ms 23776 KB Output is correct
59 Correct 15 ms 23756 KB Output is correct
60 Correct 15 ms 23732 KB Output is correct
61 Correct 15 ms 23756 KB Output is correct
62 Correct 15 ms 23804 KB Output is correct
63 Correct 15 ms 23756 KB Output is correct
64 Correct 15 ms 23780 KB Output is correct
65 Correct 16 ms 23808 KB Output is correct
66 Correct 15 ms 23776 KB Output is correct
67 Correct 14 ms 23756 KB Output is correct
68 Execution timed out 5056 ms 27288 KB Time limit exceeded
69 Halted 0 ms 0 KB -