Submission #1083586

# Submission time Handle Problem Language Result Execution time Memory
1083586 2024-09-03T14:26:05 Z _8_8_ Political Development (BOI17_politicaldevelopment) C++17
39 / 100
3000 ms 11196 KB
#include <bits/stdc++.h>

using namespace std;
    
typedef long long ll;
const int  N = 5e4 + 12, MOD = (int)1e9 + 7;

int n, k, timer = 0;
vector<int> g[N], vis[N];
int calc(vector<int> &x, int tim) {
    if(x.empty()) return 0;
    for(int i:x) {
        vis[i].push_back(tim);
    }
    int ret = 0;
    // cerr << (int)x.size() << ' ' << tim << '\n';
    for(int i:x) {
        vector<int> nv;
        for(int to:g[i]) {
            if(!vis[to].empty() && vis[to].back() == tim) {
                nv.push_back(to);
            }
        }
        ret = max(ret,1 + calc(nv, tim + 1));
    }
    for(int i:x) {
        vis[i].pop_back();
    }
    return ret;
}
void test() {
    cin >> n >> k;
    for(int i = 1; i <= n; i++) {
        int d;
        cin >> d;
        for(int j = 0; j < d; j++) {
            int x;
            cin >> x;
            ++x;
            g[x].push_back(i);
            // cout << x << ' ' << d << '\n';
        }
    }
    int res = 0;
    for(int i = 1; i <= n; i++) {
        res = max(res, 1 + calc(g[i], 1));
    }
    cout << res << '\n';
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    int t = 1; 
    // cin >> t;
    while(t--) 
        test();

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2652 KB Output is correct
2 Correct 1 ms 2652 KB Output is correct
3 Correct 3 ms 3164 KB Output is correct
4 Correct 20 ms 3164 KB Output is correct
5 Correct 20 ms 3040 KB Output is correct
6 Correct 5 ms 3072 KB Output is correct
7 Correct 3 ms 3164 KB Output is correct
8 Correct 1 ms 2652 KB Output is correct
9 Correct 1 ms 2652 KB Output is correct
10 Correct 1 ms 2652 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2652 KB Output is correct
2 Correct 1 ms 2652 KB Output is correct
3 Correct 3 ms 3164 KB Output is correct
4 Correct 20 ms 3164 KB Output is correct
5 Correct 20 ms 3040 KB Output is correct
6 Correct 5 ms 3072 KB Output is correct
7 Correct 3 ms 3164 KB Output is correct
8 Correct 1 ms 2652 KB Output is correct
9 Correct 1 ms 2652 KB Output is correct
10 Correct 1 ms 2652 KB Output is correct
11 Correct 22 ms 3164 KB Output is correct
12 Correct 21 ms 3160 KB Output is correct
13 Correct 1 ms 2648 KB Output is correct
14 Correct 19 ms 3064 KB Output is correct
15 Correct 1 ms 2652 KB Output is correct
16 Correct 3 ms 3072 KB Output is correct
17 Correct 1 ms 2652 KB Output is correct
18 Correct 3 ms 3164 KB Output is correct
19 Correct 1 ms 2652 KB Output is correct
20 Correct 3 ms 2908 KB Output is correct
21 Correct 3 ms 2908 KB Output is correct
22 Correct 2 ms 2648 KB Output is correct
23 Correct 3 ms 3164 KB Output is correct
24 Correct 2 ms 2652 KB Output is correct
25 Correct 3 ms 3164 KB Output is correct
26 Correct 4 ms 3164 KB Output is correct
27 Correct 3 ms 3164 KB Output is correct
28 Correct 3 ms 3164 KB Output is correct
29 Correct 2 ms 3076 KB Output is correct
30 Correct 8 ms 3160 KB Output is correct
31 Correct 3 ms 3164 KB Output is correct
32 Correct 9 ms 3164 KB Output is correct
33 Correct 3 ms 3160 KB Output is correct
34 Correct 3 ms 3164 KB Output is correct
35 Correct 3 ms 2908 KB Output is correct
36 Correct 2 ms 2904 KB Output is correct
37 Correct 3 ms 2904 KB Output is correct
38 Correct 3 ms 2908 KB Output is correct
39 Correct 2 ms 2816 KB Output is correct
40 Correct 5 ms 3160 KB Output is correct
41 Correct 2 ms 2908 KB Output is correct
42 Correct 5 ms 3164 KB Output is correct
43 Correct 4 ms 3164 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2652 KB Output is correct
2 Correct 1 ms 2652 KB Output is correct
3 Correct 2 ms 2652 KB Output is correct
4 Correct 2 ms 2652 KB Output is correct
5 Correct 2 ms 2652 KB Output is correct
6 Correct 1 ms 2652 KB Output is correct
7 Correct 1 ms 2652 KB Output is correct
8 Correct 1 ms 2652 KB Output is correct
9 Correct 1 ms 2652 KB Output is correct
10 Correct 1 ms 2652 KB Output is correct
11 Correct 79 ms 11196 KB Output is correct
12 Correct 2 ms 2648 KB Output is correct
13 Correct 115 ms 11088 KB Output is correct
14 Correct 1 ms 2648 KB Output is correct
15 Correct 76 ms 11088 KB Output is correct
16 Correct 81 ms 11160 KB Output is correct
17 Correct 120 ms 11092 KB Output is correct
18 Correct 78 ms 11184 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2652 KB Output is correct
2 Correct 1 ms 2652 KB Output is correct
3 Correct 3 ms 3164 KB Output is correct
4 Correct 20 ms 3164 KB Output is correct
5 Correct 20 ms 3040 KB Output is correct
6 Correct 5 ms 3072 KB Output is correct
7 Correct 3 ms 3164 KB Output is correct
8 Correct 1 ms 2652 KB Output is correct
9 Correct 1 ms 2652 KB Output is correct
10 Correct 1 ms 2652 KB Output is correct
11 Correct 22 ms 3164 KB Output is correct
12 Correct 21 ms 3160 KB Output is correct
13 Correct 1 ms 2648 KB Output is correct
14 Correct 19 ms 3064 KB Output is correct
15 Correct 1 ms 2652 KB Output is correct
16 Correct 3 ms 3072 KB Output is correct
17 Correct 1 ms 2652 KB Output is correct
18 Correct 3 ms 3164 KB Output is correct
19 Correct 1 ms 2652 KB Output is correct
20 Correct 3 ms 2908 KB Output is correct
21 Correct 3 ms 2908 KB Output is correct
22 Correct 2 ms 2648 KB Output is correct
23 Correct 3 ms 3164 KB Output is correct
24 Correct 2 ms 2652 KB Output is correct
25 Correct 3 ms 3164 KB Output is correct
26 Correct 4 ms 3164 KB Output is correct
27 Correct 3 ms 3164 KB Output is correct
28 Correct 3 ms 3164 KB Output is correct
29 Correct 2 ms 3076 KB Output is correct
30 Correct 8 ms 3160 KB Output is correct
31 Correct 3 ms 3164 KB Output is correct
32 Correct 9 ms 3164 KB Output is correct
33 Correct 3 ms 3160 KB Output is correct
34 Correct 3 ms 3164 KB Output is correct
35 Correct 3 ms 2908 KB Output is correct
36 Correct 2 ms 2904 KB Output is correct
37 Correct 3 ms 2904 KB Output is correct
38 Correct 3 ms 2908 KB Output is correct
39 Correct 2 ms 2816 KB Output is correct
40 Correct 5 ms 3160 KB Output is correct
41 Correct 2 ms 2908 KB Output is correct
42 Correct 5 ms 3164 KB Output is correct
43 Correct 4 ms 3164 KB Output is correct
44 Execution timed out 3044 ms 3400 KB Time limit exceeded
45 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2652 KB Output is correct
2 Correct 1 ms 2652 KB Output is correct
3 Correct 3 ms 3164 KB Output is correct
4 Correct 20 ms 3164 KB Output is correct
5 Correct 20 ms 3040 KB Output is correct
6 Correct 5 ms 3072 KB Output is correct
7 Correct 3 ms 3164 KB Output is correct
8 Correct 1 ms 2652 KB Output is correct
9 Correct 1 ms 2652 KB Output is correct
10 Correct 1 ms 2652 KB Output is correct
11 Correct 22 ms 3164 KB Output is correct
12 Correct 21 ms 3160 KB Output is correct
13 Correct 1 ms 2648 KB Output is correct
14 Correct 19 ms 3064 KB Output is correct
15 Correct 1 ms 2652 KB Output is correct
16 Correct 3 ms 3072 KB Output is correct
17 Correct 1 ms 2652 KB Output is correct
18 Correct 3 ms 3164 KB Output is correct
19 Correct 1 ms 2652 KB Output is correct
20 Correct 3 ms 2908 KB Output is correct
21 Correct 3 ms 2908 KB Output is correct
22 Correct 2 ms 2648 KB Output is correct
23 Correct 3 ms 3164 KB Output is correct
24 Correct 2 ms 2652 KB Output is correct
25 Correct 3 ms 3164 KB Output is correct
26 Correct 4 ms 3164 KB Output is correct
27 Correct 3 ms 3164 KB Output is correct
28 Correct 3 ms 3164 KB Output is correct
29 Correct 2 ms 3076 KB Output is correct
30 Correct 8 ms 3160 KB Output is correct
31 Correct 3 ms 3164 KB Output is correct
32 Correct 9 ms 3164 KB Output is correct
33 Correct 3 ms 3160 KB Output is correct
34 Correct 3 ms 3164 KB Output is correct
35 Correct 3 ms 2908 KB Output is correct
36 Correct 2 ms 2904 KB Output is correct
37 Correct 3 ms 2904 KB Output is correct
38 Correct 3 ms 2908 KB Output is correct
39 Correct 2 ms 2816 KB Output is correct
40 Correct 5 ms 3160 KB Output is correct
41 Correct 2 ms 2908 KB Output is correct
42 Correct 5 ms 3164 KB Output is correct
43 Correct 4 ms 3164 KB Output is correct
44 Correct 2 ms 2652 KB Output is correct
45 Correct 54 ms 8444 KB Output is correct
46 Correct 616 ms 6720 KB Output is correct
47 Correct 53 ms 8536 KB Output is correct
48 Correct 51 ms 8368 KB Output is correct
49 Correct 1856 ms 6656 KB Output is correct
50 Execution timed out 3039 ms 9028 KB Time limit exceeded
51 Halted 0 ms 0 KB -