Submission #940433

# Submission time Handle Problem Language Result Execution time Memory
940433 2024-03-07T09:11:52 Z phoenix0423 Political Development (BOI17_politicaldevelopment) C++17
100 / 100
67 ms 24524 KB
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
#define fastio ios::sync_with_stdio(false), cin.tie(0)
#pragma GCC optimize("Ofast")
#define pb push_back
#define eb emplace_back
#define f first
#define s second
#define int long long
const int maxn = 2e5 + 5;
vector<int> adj[maxn], nadj[maxn];
int deg[maxn];
 
signed main(void){
    fastio;
    int n, k;
    cin>>n>>k;
    for(int i = 0; i < n; i++){
        int d;
        cin>>d;
        deg[i] = d;
        for(int j = 0; j < d; j++){
            int x;
            cin>>x;
            adj[i].pb(x);
        }
    }
    for(int i = 0; i < n; i++){
        for(auto x : adj[i]){
            if(deg[i] < deg[x]) nadj[i].pb(x);
            else if(deg[i] == deg[x] && i < x) nadj[i].pb(x);
        }
    }
    int ans = 0;
    auto dfs = [&](auto self, int pos, int ttl, vector<int>& cnt) -> void{
        ans = max(ans, ttl);
        for(auto x : nadj[pos]) cnt[x]++;
        for(auto x : nadj[pos]){
            if(cnt[x] >= ttl){
                self(self, x, ttl + 1, cnt);
            }
        }
        for(auto x : nadj[pos]) cnt[x] --;
    };
    vector<int> cnt(n);
    for(int i = 0; i < n; i++){
        dfs(dfs, i, 1, cnt);
    }
    cout<<ans<<"\n";
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 11244 KB Output is correct
2 Correct 2 ms 11100 KB Output is correct
3 Correct 5 ms 11612 KB Output is correct
4 Correct 4 ms 11608 KB Output is correct
5 Correct 4 ms 11612 KB Output is correct
6 Correct 4 ms 11768 KB Output is correct
7 Correct 3 ms 11612 KB Output is correct
8 Correct 3 ms 11100 KB Output is correct
9 Correct 2 ms 11240 KB Output is correct
10 Correct 3 ms 11096 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 11244 KB Output is correct
2 Correct 2 ms 11100 KB Output is correct
3 Correct 5 ms 11612 KB Output is correct
4 Correct 4 ms 11608 KB Output is correct
5 Correct 4 ms 11612 KB Output is correct
6 Correct 4 ms 11768 KB Output is correct
7 Correct 3 ms 11612 KB Output is correct
8 Correct 3 ms 11100 KB Output is correct
9 Correct 2 ms 11240 KB Output is correct
10 Correct 3 ms 11096 KB Output is correct
11 Correct 4 ms 11612 KB Output is correct
12 Correct 4 ms 11520 KB Output is correct
13 Correct 3 ms 11100 KB Output is correct
14 Correct 4 ms 11612 KB Output is correct
15 Correct 3 ms 11100 KB Output is correct
16 Correct 4 ms 11612 KB Output is correct
17 Correct 2 ms 11100 KB Output is correct
18 Correct 4 ms 11612 KB Output is correct
19 Correct 3 ms 11100 KB Output is correct
20 Correct 3 ms 11356 KB Output is correct
21 Correct 3 ms 11352 KB Output is correct
22 Correct 2 ms 11100 KB Output is correct
23 Correct 4 ms 11612 KB Output is correct
24 Correct 2 ms 11096 KB Output is correct
25 Correct 4 ms 11628 KB Output is correct
26 Correct 4 ms 11612 KB Output is correct
27 Correct 4 ms 11612 KB Output is correct
28 Correct 4 ms 11612 KB Output is correct
29 Correct 4 ms 11508 KB Output is correct
30 Correct 4 ms 11612 KB Output is correct
31 Correct 4 ms 11612 KB Output is correct
32 Correct 4 ms 11612 KB Output is correct
33 Correct 4 ms 11612 KB Output is correct
34 Correct 4 ms 11612 KB Output is correct
35 Correct 3 ms 11356 KB Output is correct
36 Correct 3 ms 11356 KB Output is correct
37 Correct 3 ms 11356 KB Output is correct
38 Correct 3 ms 11356 KB Output is correct
39 Correct 3 ms 11180 KB Output is correct
40 Correct 5 ms 11652 KB Output is correct
41 Correct 3 ms 11356 KB Output is correct
42 Correct 5 ms 11608 KB Output is correct
43 Correct 5 ms 11612 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 11100 KB Output is correct
2 Correct 2 ms 11100 KB Output is correct
3 Correct 2 ms 11244 KB Output is correct
4 Correct 3 ms 11100 KB Output is correct
5 Correct 3 ms 11100 KB Output is correct
6 Correct 3 ms 11240 KB Output is correct
7 Correct 2 ms 11100 KB Output is correct
8 Correct 2 ms 11100 KB Output is correct
9 Correct 3 ms 11104 KB Output is correct
10 Correct 3 ms 11100 KB Output is correct
11 Correct 60 ms 24288 KB Output is correct
12 Correct 3 ms 11100 KB Output is correct
13 Correct 58 ms 24404 KB Output is correct
14 Correct 3 ms 11112 KB Output is correct
15 Correct 67 ms 24448 KB Output is correct
16 Correct 58 ms 24524 KB Output is correct
17 Correct 58 ms 24408 KB Output is correct
18 Correct 58 ms 24404 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 11244 KB Output is correct
2 Correct 2 ms 11100 KB Output is correct
3 Correct 5 ms 11612 KB Output is correct
4 Correct 4 ms 11608 KB Output is correct
5 Correct 4 ms 11612 KB Output is correct
6 Correct 4 ms 11768 KB Output is correct
7 Correct 3 ms 11612 KB Output is correct
8 Correct 3 ms 11100 KB Output is correct
9 Correct 2 ms 11240 KB Output is correct
10 Correct 3 ms 11096 KB Output is correct
11 Correct 4 ms 11612 KB Output is correct
12 Correct 4 ms 11520 KB Output is correct
13 Correct 3 ms 11100 KB Output is correct
14 Correct 4 ms 11612 KB Output is correct
15 Correct 3 ms 11100 KB Output is correct
16 Correct 4 ms 11612 KB Output is correct
17 Correct 2 ms 11100 KB Output is correct
18 Correct 4 ms 11612 KB Output is correct
19 Correct 3 ms 11100 KB Output is correct
20 Correct 3 ms 11356 KB Output is correct
21 Correct 3 ms 11352 KB Output is correct
22 Correct 2 ms 11100 KB Output is correct
23 Correct 4 ms 11612 KB Output is correct
24 Correct 2 ms 11096 KB Output is correct
25 Correct 4 ms 11628 KB Output is correct
26 Correct 4 ms 11612 KB Output is correct
27 Correct 4 ms 11612 KB Output is correct
28 Correct 4 ms 11612 KB Output is correct
29 Correct 4 ms 11508 KB Output is correct
30 Correct 4 ms 11612 KB Output is correct
31 Correct 4 ms 11612 KB Output is correct
32 Correct 4 ms 11612 KB Output is correct
33 Correct 4 ms 11612 KB Output is correct
34 Correct 4 ms 11612 KB Output is correct
35 Correct 3 ms 11356 KB Output is correct
36 Correct 3 ms 11356 KB Output is correct
37 Correct 3 ms 11356 KB Output is correct
38 Correct 3 ms 11356 KB Output is correct
39 Correct 3 ms 11180 KB Output is correct
40 Correct 5 ms 11652 KB Output is correct
41 Correct 3 ms 11356 KB Output is correct
42 Correct 5 ms 11608 KB Output is correct
43 Correct 5 ms 11612 KB Output is correct
44 Correct 8 ms 12128 KB Output is correct
45 Correct 3 ms 11100 KB Output is correct
46 Correct 7 ms 12024 KB Output is correct
47 Correct 7 ms 12124 KB Output is correct
48 Correct 5 ms 11768 KB Output is correct
49 Correct 10 ms 12144 KB Output is correct
50 Correct 7 ms 12284 KB Output is correct
51 Correct 11 ms 13148 KB Output is correct
52 Correct 4 ms 11612 KB Output is correct
53 Correct 10 ms 13472 KB Output is correct
54 Correct 13 ms 13436 KB Output is correct
55 Correct 4 ms 11612 KB Output is correct
56 Correct 4 ms 11728 KB Output is correct
57 Correct 3 ms 11100 KB Output is correct
58 Correct 12 ms 13916 KB Output is correct
59 Correct 5 ms 11612 KB Output is correct
60 Correct 4 ms 11612 KB Output is correct
61 Correct 5 ms 11612 KB Output is correct
62 Correct 5 ms 11612 KB Output is correct
63 Correct 9 ms 12164 KB Output is correct
64 Correct 7 ms 12124 KB Output is correct
65 Correct 5 ms 11608 KB Output is correct
66 Correct 5 ms 11608 KB Output is correct
67 Correct 8 ms 12376 KB Output is correct
68 Correct 7 ms 11896 KB Output is correct
69 Correct 5 ms 11612 KB Output is correct
70 Correct 7 ms 12124 KB Output is correct
71 Correct 9 ms 12424 KB Output is correct
72 Correct 8 ms 12380 KB Output is correct
73 Correct 4 ms 11612 KB Output is correct
74 Correct 7 ms 11984 KB Output is correct
75 Correct 8 ms 12380 KB Output is correct
76 Correct 6 ms 11868 KB Output is correct
77 Correct 9 ms 12584 KB Output is correct
78 Correct 4 ms 11612 KB Output is correct
79 Correct 7 ms 11916 KB Output is correct
80 Correct 6 ms 11868 KB Output is correct
81 Correct 9 ms 12556 KB Output is correct
82 Correct 3 ms 11352 KB Output is correct
83 Correct 7 ms 11868 KB Output is correct
84 Correct 8 ms 12380 KB Output is correct
85 Correct 4 ms 11356 KB Output is correct
86 Correct 9 ms 12376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 11244 KB Output is correct
2 Correct 2 ms 11100 KB Output is correct
3 Correct 5 ms 11612 KB Output is correct
4 Correct 4 ms 11608 KB Output is correct
5 Correct 4 ms 11612 KB Output is correct
6 Correct 4 ms 11768 KB Output is correct
7 Correct 3 ms 11612 KB Output is correct
8 Correct 3 ms 11100 KB Output is correct
9 Correct 2 ms 11240 KB Output is correct
10 Correct 3 ms 11096 KB Output is correct
11 Correct 4 ms 11612 KB Output is correct
12 Correct 4 ms 11520 KB Output is correct
13 Correct 3 ms 11100 KB Output is correct
14 Correct 4 ms 11612 KB Output is correct
15 Correct 3 ms 11100 KB Output is correct
16 Correct 4 ms 11612 KB Output is correct
17 Correct 2 ms 11100 KB Output is correct
18 Correct 4 ms 11612 KB Output is correct
19 Correct 3 ms 11100 KB Output is correct
20 Correct 3 ms 11356 KB Output is correct
21 Correct 3 ms 11352 KB Output is correct
22 Correct 2 ms 11100 KB Output is correct
23 Correct 4 ms 11612 KB Output is correct
24 Correct 2 ms 11096 KB Output is correct
25 Correct 4 ms 11628 KB Output is correct
26 Correct 4 ms 11612 KB Output is correct
27 Correct 4 ms 11612 KB Output is correct
28 Correct 4 ms 11612 KB Output is correct
29 Correct 4 ms 11508 KB Output is correct
30 Correct 4 ms 11612 KB Output is correct
31 Correct 4 ms 11612 KB Output is correct
32 Correct 4 ms 11612 KB Output is correct
33 Correct 4 ms 11612 KB Output is correct
34 Correct 4 ms 11612 KB Output is correct
35 Correct 3 ms 11356 KB Output is correct
36 Correct 3 ms 11356 KB Output is correct
37 Correct 3 ms 11356 KB Output is correct
38 Correct 3 ms 11356 KB Output is correct
39 Correct 3 ms 11180 KB Output is correct
40 Correct 5 ms 11652 KB Output is correct
41 Correct 3 ms 11356 KB Output is correct
42 Correct 5 ms 11608 KB Output is correct
43 Correct 5 ms 11612 KB Output is correct
44 Correct 3 ms 11100 KB Output is correct
45 Correct 45 ms 19712 KB Output is correct
46 Correct 23 ms 16084 KB Output is correct
47 Correct 43 ms 19640 KB Output is correct
48 Correct 42 ms 19540 KB Output is correct
49 Correct 15 ms 15828 KB Output is correct
50 Correct 39 ms 20196 KB Output is correct
51 Correct 42 ms 19548 KB Output is correct
52 Correct 19 ms 15964 KB Output is correct
53 Correct 15 ms 16088 KB Output is correct
54 Correct 5 ms 11864 KB Output is correct
55 Correct 39 ms 20308 KB Output is correct
56 Correct 11 ms 14428 KB Output is correct
57 Correct 15 ms 15952 KB Output is correct
58 Correct 27 ms 16376 KB Output is correct
59 Correct 11 ms 14424 KB Output is correct
60 Correct 12 ms 14408 KB Output is correct
61 Correct 24 ms 16380 KB Output is correct
62 Correct 18 ms 14936 KB Output is correct
63 Correct 28 ms 16980 KB Output is correct
64 Correct 11 ms 14400 KB Output is correct
65 Correct 39 ms 17868 KB Output is correct
66 Correct 17 ms 14976 KB Output is correct
67 Correct 28 ms 16980 KB Output is correct
68 Correct 33 ms 17752 KB Output is correct
69 Correct 35 ms 18012 KB Output is correct
70 Correct 18 ms 14940 KB Output is correct
71 Correct 33 ms 17608 KB Output is correct
72 Correct 25 ms 16860 KB Output is correct
73 Correct 37 ms 18524 KB Output is correct
74 Correct 17 ms 15188 KB Output is correct
75 Correct 16 ms 14172 KB Output is correct
76 Correct 25 ms 16852 KB Output is correct
77 Correct 36 ms 18408 KB Output is correct
78 Correct 19 ms 14940 KB Output is correct
79 Correct 16 ms 14168 KB Output is correct
80 Correct 9 ms 12636 KB Output is correct
81 Correct 20 ms 14936 KB Output is correct
82 Correct 35 ms 16724 KB Output is correct
83 Correct 8 ms 12636 KB Output is correct
84 Correct 27 ms 16732 KB Output is correct