Submission #439547

# Submission time Handle Problem Language Result Execution time Memory
439547 2021-06-30T08:20:14 Z K4YAN Political Development (BOI17_politicaldevelopment) C++17
54 / 100
2001 ms 47452 KB
//Be Name Khoda
// 10:55 -> 10:50 shoroo
// 12:40 | 12:40
 
#include<bits/stdc++.h>
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
#define all(x) x.begin(), x.end()
#define pll pair<ll, ll>
#define pii pair<int, int>
#define plll pair<pll, ll>
#define piii pair<pii, int>
#define piiii pair<pii, pii>
 
const short int mxn = 5e3 + 1;
int n, k, q, w;
short int v, deg[mxn];
vector<int> dp[mxn][11];
vector<short int> kmk, g2[11];
vector<vector<short int>> g[11];
bool edge[mxn][mxn];
 
void input() {
 
    int tmp = 0;
    cin >> n >> k;
    for(short int i = 0; i < n; i++) {
        cin >> q;
        deg[i] = q;
        for(short int j = 0; j < q; j++) {
            cin >> v;
            edge[v][i] = 1;
            if(i < v) {
                dp[i][2].push_back(tmp);
                dp[v][2].push_back(tmp++);
                g[2].push_back({i, v});
                if(deg[i] < deg[v]) {
                    g2[2].push_back(i);
                }
                else {
                    g2[2].push_back(v);
                }
            }
        }
    }
 
}
 
void solve() {
 
    bool b;
    int tmp;
    for(int i = 3; i <= k; i++) {
        tmp = 0;
 
        for(int j = 0; j < n; j++) {
 
            for(w = 0; w < (int)(g[i - 1].size()); w++) {
                if(dp[j][i].size() >= 20) {
                    break;
                }
                
                if(edge[j][g2[i - 1][w]] == false) {
                    continue;
                }
                b = true;
                for(auto e : g[i - 1][w]) {
 
                    if(edge[j][e] == false) {
                        b = false;
                        break;
                    }
 
                }
 
                if(b == false) {
                    continue;
                }
                for(auto e : g[i - 1][w]) {
                    kmk.push_back(e);
                    dp[e][i].push_back(tmp);
                }
                dp[j][i].push_back(tmp++);
                kmk.push_back(j);
                g[i].push_back(kmk);
                if(deg[g2[i - 1][w]] > deg[j]) {
                    g2[i].push_back(j);
                }
                else {
                    g2[i].push_back(g2[i - 1][w]);
                }
                kmk.clear();
            }
        }
        if(int(g[i].size()) == 0) {
            break;
        }
    }
 
    for(short int i = 2; i <= k; i++) {
        if(int(g[i].size()) == 0) {
            cout << i - 1 << endl;
            return;
        }
    }
    cout << k << endl;
    return;
 
}
 
int main() {
 
    ios_base::sync_with_stdio(false);
 
    input(), solve();
 
    return 0;
 
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1612 KB Output is correct
2 Correct 1 ms 1612 KB Output is correct
3 Correct 13 ms 23048 KB Output is correct
4 Correct 12 ms 22092 KB Output is correct
5 Correct 11 ms 22160 KB Output is correct
6 Correct 12 ms 19916 KB Output is correct
7 Correct 12 ms 20024 KB Output is correct
8 Correct 2 ms 1612 KB Output is correct
9 Correct 1 ms 1580 KB Output is correct
10 Correct 3 ms 1612 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1612 KB Output is correct
2 Correct 1 ms 1612 KB Output is correct
3 Correct 13 ms 23048 KB Output is correct
4 Correct 12 ms 22092 KB Output is correct
5 Correct 11 ms 22160 KB Output is correct
6 Correct 12 ms 19916 KB Output is correct
7 Correct 12 ms 20024 KB Output is correct
8 Correct 2 ms 1612 KB Output is correct
9 Correct 1 ms 1580 KB Output is correct
10 Correct 3 ms 1612 KB Output is correct
11 Correct 12 ms 22092 KB Output is correct
12 Correct 97 ms 22200 KB Output is correct
13 Correct 1 ms 1612 KB Output is correct
14 Correct 101 ms 22196 KB Output is correct
15 Correct 1 ms 1612 KB Output is correct
16 Correct 104 ms 19992 KB Output is correct
17 Correct 1 ms 1612 KB Output is correct
18 Correct 99 ms 19900 KB Output is correct
19 Correct 2 ms 1612 KB Output is correct
20 Correct 56 ms 19660 KB Output is correct
21 Correct 55 ms 19652 KB Output is correct
22 Correct 5 ms 1612 KB Output is correct
23 Correct 116 ms 24652 KB Output is correct
24 Correct 5 ms 1612 KB Output is correct
25 Correct 127 ms 24600 KB Output is correct
26 Correct 114 ms 23856 KB Output is correct
27 Correct 110 ms 24584 KB Output is correct
28 Correct 109 ms 23712 KB Output is correct
29 Correct 107 ms 24740 KB Output is correct
30 Correct 142 ms 24156 KB Output is correct
31 Correct 134 ms 25528 KB Output is correct
32 Correct 133 ms 24396 KB Output is correct
33 Correct 136 ms 25516 KB Output is correct
34 Correct 130 ms 25548 KB Output is correct
35 Correct 37 ms 13492 KB Output is correct
36 Correct 37 ms 13528 KB Output is correct
37 Correct 37 ms 13388 KB Output is correct
38 Correct 15 ms 7332 KB Output is correct
39 Correct 17 ms 7336 KB Output is correct
40 Correct 182 ms 26364 KB Output is correct
41 Correct 15 ms 7244 KB Output is correct
42 Correct 194 ms 26260 KB Output is correct
43 Correct 186 ms 26188 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 1612 KB Output is correct
2 Correct 1 ms 1612 KB Output is correct
3 Correct 1 ms 1612 KB Output is correct
4 Correct 1 ms 1612 KB Output is correct
5 Correct 1 ms 1612 KB Output is correct
6 Correct 1 ms 1612 KB Output is correct
7 Correct 1 ms 1612 KB Output is correct
8 Correct 1 ms 1612 KB Output is correct
9 Correct 1 ms 1612 KB Output is correct
10 Correct 2 ms 1612 KB Output is correct
11 Runtime error 4 ms 3032 KB Execution killed with signal 11
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1612 KB Output is correct
2 Correct 1 ms 1612 KB Output is correct
3 Correct 13 ms 23048 KB Output is correct
4 Correct 12 ms 22092 KB Output is correct
5 Correct 11 ms 22160 KB Output is correct
6 Correct 12 ms 19916 KB Output is correct
7 Correct 12 ms 20024 KB Output is correct
8 Correct 2 ms 1612 KB Output is correct
9 Correct 1 ms 1580 KB Output is correct
10 Correct 3 ms 1612 KB Output is correct
11 Correct 12 ms 22092 KB Output is correct
12 Correct 97 ms 22200 KB Output is correct
13 Correct 1 ms 1612 KB Output is correct
14 Correct 101 ms 22196 KB Output is correct
15 Correct 1 ms 1612 KB Output is correct
16 Correct 104 ms 19992 KB Output is correct
17 Correct 1 ms 1612 KB Output is correct
18 Correct 99 ms 19900 KB Output is correct
19 Correct 2 ms 1612 KB Output is correct
20 Correct 56 ms 19660 KB Output is correct
21 Correct 55 ms 19652 KB Output is correct
22 Correct 5 ms 1612 KB Output is correct
23 Correct 116 ms 24652 KB Output is correct
24 Correct 5 ms 1612 KB Output is correct
25 Correct 127 ms 24600 KB Output is correct
26 Correct 114 ms 23856 KB Output is correct
27 Correct 110 ms 24584 KB Output is correct
28 Correct 109 ms 23712 KB Output is correct
29 Correct 107 ms 24740 KB Output is correct
30 Correct 142 ms 24156 KB Output is correct
31 Correct 134 ms 25528 KB Output is correct
32 Correct 133 ms 24396 KB Output is correct
33 Correct 136 ms 25516 KB Output is correct
34 Correct 130 ms 25548 KB Output is correct
35 Correct 37 ms 13492 KB Output is correct
36 Correct 37 ms 13528 KB Output is correct
37 Correct 37 ms 13388 KB Output is correct
38 Correct 15 ms 7332 KB Output is correct
39 Correct 17 ms 7336 KB Output is correct
40 Correct 182 ms 26364 KB Output is correct
41 Correct 15 ms 7244 KB Output is correct
42 Correct 194 ms 26260 KB Output is correct
43 Correct 186 ms 26188 KB Output is correct
44 Correct 1966 ms 47292 KB Output is correct
45 Correct 1 ms 1612 KB Output is correct
46 Correct 194 ms 25840 KB Output is correct
47 Correct 388 ms 27716 KB Output is correct
48 Correct 189 ms 25864 KB Output is correct
49 Correct 392 ms 27608 KB Output is correct
50 Correct 393 ms 27472 KB Output is correct
51 Correct 851 ms 29460 KB Output is correct
52 Correct 12 ms 22092 KB Output is correct
53 Correct 922 ms 29300 KB Output is correct
54 Correct 945 ms 29768 KB Output is correct
55 Correct 104 ms 20004 KB Output is correct
56 Correct 12 ms 22216 KB Output is correct
57 Correct 2 ms 1624 KB Output is correct
58 Correct 984 ms 29768 KB Output is correct
59 Correct 1146 ms 33608 KB Output is correct
60 Correct 101 ms 20044 KB Output is correct
61 Correct 1099 ms 33604 KB Output is correct
62 Correct 1117 ms 33556 KB Output is correct
63 Correct 2001 ms 47452 KB Output is correct
64 Correct 1809 ms 43920 KB Output is correct
65 Correct 189 ms 25984 KB Output is correct
66 Correct 1091 ms 33560 KB Output is correct
67 Correct 1204 ms 33140 KB Output is correct
68 Correct 1808 ms 43760 KB Output is correct
69 Correct 195 ms 25856 KB Output is correct
70 Correct 765 ms 30076 KB Output is correct
71 Correct 1198 ms 33136 KB Output is correct
72 Correct 1082 ms 32208 KB Output is correct
73 Correct 105 ms 24544 KB Output is correct
74 Correct 767 ms 30032 KB Output is correct
75 Correct 1093 ms 31988 KB Output is correct
76 Correct 323 ms 26912 KB Output is correct
77 Correct 529 ms 28444 KB Output is correct
78 Correct 105 ms 24652 KB Output is correct
79 Correct 144 ms 15052 KB Output is correct
80 Correct 260 ms 26888 KB Output is correct
81 Correct 508 ms 28428 KB Output is correct
82 Correct 16 ms 7356 KB Output is correct
83 Correct 136 ms 15052 KB Output is correct
84 Correct 421 ms 28044 KB Output is correct
85 Correct 15 ms 7244 KB Output is correct
86 Correct 418 ms 28028 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1612 KB Output is correct
2 Correct 1 ms 1612 KB Output is correct
3 Correct 13 ms 23048 KB Output is correct
4 Correct 12 ms 22092 KB Output is correct
5 Correct 11 ms 22160 KB Output is correct
6 Correct 12 ms 19916 KB Output is correct
7 Correct 12 ms 20024 KB Output is correct
8 Correct 2 ms 1612 KB Output is correct
9 Correct 1 ms 1580 KB Output is correct
10 Correct 3 ms 1612 KB Output is correct
11 Correct 12 ms 22092 KB Output is correct
12 Correct 97 ms 22200 KB Output is correct
13 Correct 1 ms 1612 KB Output is correct
14 Correct 101 ms 22196 KB Output is correct
15 Correct 1 ms 1612 KB Output is correct
16 Correct 104 ms 19992 KB Output is correct
17 Correct 1 ms 1612 KB Output is correct
18 Correct 99 ms 19900 KB Output is correct
19 Correct 2 ms 1612 KB Output is correct
20 Correct 56 ms 19660 KB Output is correct
21 Correct 55 ms 19652 KB Output is correct
22 Correct 5 ms 1612 KB Output is correct
23 Correct 116 ms 24652 KB Output is correct
24 Correct 5 ms 1612 KB Output is correct
25 Correct 127 ms 24600 KB Output is correct
26 Correct 114 ms 23856 KB Output is correct
27 Correct 110 ms 24584 KB Output is correct
28 Correct 109 ms 23712 KB Output is correct
29 Correct 107 ms 24740 KB Output is correct
30 Correct 142 ms 24156 KB Output is correct
31 Correct 134 ms 25528 KB Output is correct
32 Correct 133 ms 24396 KB Output is correct
33 Correct 136 ms 25516 KB Output is correct
34 Correct 130 ms 25548 KB Output is correct
35 Correct 37 ms 13492 KB Output is correct
36 Correct 37 ms 13528 KB Output is correct
37 Correct 37 ms 13388 KB Output is correct
38 Correct 15 ms 7332 KB Output is correct
39 Correct 17 ms 7336 KB Output is correct
40 Correct 182 ms 26364 KB Output is correct
41 Correct 15 ms 7244 KB Output is correct
42 Correct 194 ms 26260 KB Output is correct
43 Correct 186 ms 26188 KB Output is correct
44 Correct 1 ms 1612 KB Output is correct
45 Runtime error 4 ms 3020 KB Execution killed with signal 11
46 Halted 0 ms 0 KB -