# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
183939 | 2020-01-10T08:27:55 Z | Ruxandra985 | Political Development (BOI17_politicaldevelopment) | C++14 | 538 ms | 55280 KB |
#include <bits/stdc++.h> #define DIMN 50010 using namespace std; map <int,int> mp[DIMN]; vector <int> v[DIMN]; int grad[DIMN] , f[DIMN] , l[DIMN]; pair <int,int> dp[DIMN]; priority_queue <pair <int,int> > h; int main() { FILE *fin = stdin; FILE *fout = stdout; int n , k , i, elem , nod , vecin , x , ok , ok2 , i2 , j , sol , val , conf; fscanf (fin,"%d%d",&n,&k); for (i=0;i<n;i++){ fscanf (fin,"%d",&elem); for (j=1;j<=elem;j++){ fscanf (fin,"%d",&x); mp[i][x] = 1; v[i].push_back(x); } grad[i] = elem; h.push(make_pair(-grad[i] , i)); } sol = 1; while (!h.empty()){ nod = h.top().second; val = -h.top().first; h.pop(); if (grad[nod] != val) continue; f[nod] = 1; /// ok acum avem nodul cu cel mai mic grad /// vrei sa vezi daca poate apartine unui graf complet elem = 0; for (i=0;i<v[nod].size();i++){ vecin = v[nod][i]; if (!f[vecin]) /// nu are rost sa faci heapul mai mare decat e nevoie l[++elem] = vecin; } /// din graful complet curent face parte nod si un subset din l ok = 0; dp[++ok] = make_pair(0 , 1); /// doar nod for (i = 1 ; i <= elem ; i++){ ok2 = ok; for (j = 1 ; j <= ok2 ; j ++){ /// adaugi l[i] la configuratia dp[j].first x = l[i]; conf = dp[j].first; for (i2 = 0 ; i2 <= k ; i2++){ if ( (conf & (1 << i2)) && !mp[x][l[i2+1]] ) break; } if (i2 > k){ dp[++ok] = make_pair(conf + (1 << (i-1)) , dp[j].second + 1); sol = max(sol , dp[j].second + 1); } } } /// il eliminam for (i=0;i<v[nod].size();i++){ vecin = v[nod][i]; grad[vecin]--; if (!f[vecin]) /// nu are rost sa faci heapul mai mare decat e nevoie h.push(make_pair(-grad[vecin] , vecin)); } } fprintf (fout,"%d",sol); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 3832 KB | Output is correct |
2 | Correct | 6 ms | 3836 KB | Output is correct |
3 | Correct | 12 ms | 4600 KB | Output is correct |
4 | Correct | 11 ms | 4600 KB | Output is correct |
5 | Correct | 12 ms | 4728 KB | Output is correct |
6 | Correct | 12 ms | 4600 KB | Output is correct |
7 | Correct | 11 ms | 4600 KB | Output is correct |
8 | Correct | 8 ms | 3960 KB | Output is correct |
9 | Correct | 6 ms | 3920 KB | Output is correct |
10 | Correct | 6 ms | 3960 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 3832 KB | Output is correct |
2 | Correct | 6 ms | 3836 KB | Output is correct |
3 | Correct | 12 ms | 4600 KB | Output is correct |
4 | Correct | 11 ms | 4600 KB | Output is correct |
5 | Correct | 12 ms | 4728 KB | Output is correct |
6 | Correct | 12 ms | 4600 KB | Output is correct |
7 | Correct | 11 ms | 4600 KB | Output is correct |
8 | Correct | 8 ms | 3960 KB | Output is correct |
9 | Correct | 6 ms | 3920 KB | Output is correct |
10 | Correct | 6 ms | 3960 KB | Output is correct |
11 | Correct | 12 ms | 4600 KB | Output is correct |
12 | Correct | 10 ms | 4600 KB | Output is correct |
13 | Correct | 7 ms | 3832 KB | Output is correct |
14 | Correct | 11 ms | 4600 KB | Output is correct |
15 | Correct | 5 ms | 3832 KB | Output is correct |
16 | Correct | 13 ms | 4856 KB | Output is correct |
17 | Correct | 5 ms | 3960 KB | Output is correct |
18 | Correct | 10 ms | 4600 KB | Output is correct |
19 | Correct | 7 ms | 3960 KB | Output is correct |
20 | Correct | 8 ms | 4344 KB | Output is correct |
21 | Correct | 8 ms | 4444 KB | Output is correct |
22 | Correct | 6 ms | 3960 KB | Output is correct |
23 | Correct | 13 ms | 4780 KB | Output is correct |
24 | Correct | 6 ms | 3960 KB | Output is correct |
25 | Correct | 15 ms | 4856 KB | Output is correct |
26 | Correct | 12 ms | 4728 KB | Output is correct |
27 | Correct | 11 ms | 4600 KB | Output is correct |
28 | Correct | 12 ms | 4728 KB | Output is correct |
29 | Correct | 12 ms | 4576 KB | Output is correct |
30 | Correct | 16 ms | 4856 KB | Output is correct |
31 | Correct | 13 ms | 4856 KB | Output is correct |
32 | Correct | 13 ms | 4856 KB | Output is correct |
33 | Correct | 13 ms | 4856 KB | Output is correct |
34 | Correct | 14 ms | 4856 KB | Output is correct |
35 | Correct | 9 ms | 4344 KB | Output is correct |
36 | Correct | 9 ms | 4344 KB | Output is correct |
37 | Correct | 9 ms | 4344 KB | Output is correct |
38 | Correct | 8 ms | 4216 KB | Output is correct |
39 | Correct | 8 ms | 4188 KB | Output is correct |
40 | Correct | 17 ms | 5496 KB | Output is correct |
41 | Correct | 8 ms | 4216 KB | Output is correct |
42 | Correct | 17 ms | 5496 KB | Output is correct |
43 | Correct | 18 ms | 5404 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 4088 KB | Output is correct |
2 | Correct | 5 ms | 3832 KB | Output is correct |
3 | Correct | 5 ms | 3832 KB | Output is correct |
4 | Correct | 5 ms | 3704 KB | Output is correct |
5 | Correct | 5 ms | 3832 KB | Output is correct |
6 | Correct | 5 ms | 3832 KB | Output is correct |
7 | Correct | 6 ms | 3832 KB | Output is correct |
8 | Correct | 5 ms | 3892 KB | Output is correct |
9 | Correct | 5 ms | 3832 KB | Output is correct |
10 | Correct | 5 ms | 3832 KB | Output is correct |
11 | Correct | 534 ms | 55144 KB | Output is correct |
12 | Correct | 5 ms | 3832 KB | Output is correct |
13 | Correct | 537 ms | 55280 KB | Output is correct |
14 | Correct | 6 ms | 3832 KB | Output is correct |
15 | Correct | 513 ms | 55112 KB | Output is correct |
16 | Correct | 507 ms | 55016 KB | Output is correct |
17 | Correct | 538 ms | 54996 KB | Output is correct |
18 | Correct | 510 ms | 55012 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 3832 KB | Output is correct |
2 | Correct | 6 ms | 3836 KB | Output is correct |
3 | Correct | 12 ms | 4600 KB | Output is correct |
4 | Correct | 11 ms | 4600 KB | Output is correct |
5 | Correct | 12 ms | 4728 KB | Output is correct |
6 | Correct | 12 ms | 4600 KB | Output is correct |
7 | Correct | 11 ms | 4600 KB | Output is correct |
8 | Correct | 8 ms | 3960 KB | Output is correct |
9 | Correct | 6 ms | 3920 KB | Output is correct |
10 | Correct | 6 ms | 3960 KB | Output is correct |
11 | Correct | 12 ms | 4600 KB | Output is correct |
12 | Correct | 10 ms | 4600 KB | Output is correct |
13 | Correct | 7 ms | 3832 KB | Output is correct |
14 | Correct | 11 ms | 4600 KB | Output is correct |
15 | Correct | 5 ms | 3832 KB | Output is correct |
16 | Correct | 13 ms | 4856 KB | Output is correct |
17 | Correct | 5 ms | 3960 KB | Output is correct |
18 | Correct | 10 ms | 4600 KB | Output is correct |
19 | Correct | 7 ms | 3960 KB | Output is correct |
20 | Correct | 8 ms | 4344 KB | Output is correct |
21 | Correct | 8 ms | 4444 KB | Output is correct |
22 | Correct | 6 ms | 3960 KB | Output is correct |
23 | Correct | 13 ms | 4780 KB | Output is correct |
24 | Correct | 6 ms | 3960 KB | Output is correct |
25 | Correct | 15 ms | 4856 KB | Output is correct |
26 | Correct | 12 ms | 4728 KB | Output is correct |
27 | Correct | 11 ms | 4600 KB | Output is correct |
28 | Correct | 12 ms | 4728 KB | Output is correct |
29 | Correct | 12 ms | 4576 KB | Output is correct |
30 | Correct | 16 ms | 4856 KB | Output is correct |
31 | Correct | 13 ms | 4856 KB | Output is correct |
32 | Correct | 13 ms | 4856 KB | Output is correct |
33 | Correct | 13 ms | 4856 KB | Output is correct |
34 | Correct | 14 ms | 4856 KB | Output is correct |
35 | Correct | 9 ms | 4344 KB | Output is correct |
36 | Correct | 9 ms | 4344 KB | Output is correct |
37 | Correct | 9 ms | 4344 KB | Output is correct |
38 | Correct | 8 ms | 4216 KB | Output is correct |
39 | Correct | 8 ms | 4188 KB | Output is correct |
40 | Correct | 17 ms | 5496 KB | Output is correct |
41 | Correct | 8 ms | 4216 KB | Output is correct |
42 | Correct | 17 ms | 5496 KB | Output is correct |
43 | Correct | 18 ms | 5404 KB | Output is correct |
44 | Correct | 46 ms | 6392 KB | Output is correct |
45 | Correct | 6 ms | 3964 KB | Output is correct |
46 | Correct | 23 ms | 5496 KB | Output is correct |
47 | Correct | 45 ms | 7928 KB | Output is correct |
48 | Correct | 21 ms | 5428 KB | Output is correct |
49 | Correct | 45 ms | 7788 KB | Output is correct |
50 | Correct | 36 ms | 7852 KB | Output is correct |
51 | Correct | 111 ms | 15196 KB | Output is correct |
52 | Correct | 12 ms | 4700 KB | Output is correct |
53 | Correct | 57 ms | 9720 KB | Output is correct |
54 | Correct | 177 ms | 17516 KB | Output is correct |
55 | Correct | 12 ms | 4728 KB | Output is correct |
56 | Correct | 28 ms | 4728 KB | Output is correct |
57 | Correct | 7 ms | 3960 KB | Output is correct |
58 | Correct | 66 ms | 9972 KB | Output is correct |
59 | Correct | 19 ms | 5112 KB | Output is correct |
60 | Correct | 11 ms | 4600 KB | Output is correct |
61 | Correct | 15 ms | 5112 KB | Output is correct |
62 | Correct | 18 ms | 5112 KB | Output is correct |
63 | Correct | 46 ms | 6264 KB | Output is correct |
64 | Correct | 33 ms | 6136 KB | Output is correct |
65 | Correct | 16 ms | 5368 KB | Output is correct |
66 | Correct | 15 ms | 5112 KB | Output is correct |
67 | Correct | 67 ms | 8908 KB | Output is correct |
68 | Correct | 35 ms | 6136 KB | Output is correct |
69 | Correct | 17 ms | 5240 KB | Output is correct |
70 | Correct | 38 ms | 7164 KB | Output is correct |
71 | Correct | 64 ms | 8696 KB | Output is correct |
72 | Correct | 47 ms | 8692 KB | Output is correct |
73 | Correct | 10 ms | 4600 KB | Output is correct |
74 | Correct | 31 ms | 7288 KB | Output is correct |
75 | Correct | 46 ms | 8692 KB | Output is correct |
76 | Correct | 20 ms | 6136 KB | Output is correct |
77 | Correct | 65 ms | 11124 KB | Output is correct |
78 | Correct | 11 ms | 4728 KB | Output is correct |
79 | Correct | 29 ms | 7420 KB | Output is correct |
80 | Correct | 21 ms | 6136 KB | Output is correct |
81 | Correct | 57 ms | 11124 KB | Output is correct |
82 | Correct | 8 ms | 4216 KB | Output is correct |
83 | Correct | 31 ms | 7416 KB | Output is correct |
84 | Correct | 41 ms | 8948 KB | Output is correct |
85 | Correct | 8 ms | 4216 KB | Output is correct |
86 | Correct | 41 ms | 8820 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 3832 KB | Output is correct |
2 | Correct | 6 ms | 3836 KB | Output is correct |
3 | Correct | 12 ms | 4600 KB | Output is correct |
4 | Correct | 11 ms | 4600 KB | Output is correct |
5 | Correct | 12 ms | 4728 KB | Output is correct |
6 | Correct | 12 ms | 4600 KB | Output is correct |
7 | Correct | 11 ms | 4600 KB | Output is correct |
8 | Correct | 8 ms | 3960 KB | Output is correct |
9 | Correct | 6 ms | 3920 KB | Output is correct |
10 | Correct | 6 ms | 3960 KB | Output is correct |
11 | Correct | 12 ms | 4600 KB | Output is correct |
12 | Correct | 10 ms | 4600 KB | Output is correct |
13 | Correct | 7 ms | 3832 KB | Output is correct |
14 | Correct | 11 ms | 4600 KB | Output is correct |
15 | Correct | 5 ms | 3832 KB | Output is correct |
16 | Correct | 13 ms | 4856 KB | Output is correct |
17 | Correct | 5 ms | 3960 KB | Output is correct |
18 | Correct | 10 ms | 4600 KB | Output is correct |
19 | Correct | 7 ms | 3960 KB | Output is correct |
20 | Correct | 8 ms | 4344 KB | Output is correct |
21 | Correct | 8 ms | 4444 KB | Output is correct |
22 | Correct | 6 ms | 3960 KB | Output is correct |
23 | Correct | 13 ms | 4780 KB | Output is correct |
24 | Correct | 6 ms | 3960 KB | Output is correct |
25 | Correct | 15 ms | 4856 KB | Output is correct |
26 | Correct | 12 ms | 4728 KB | Output is correct |
27 | Correct | 11 ms | 4600 KB | Output is correct |
28 | Correct | 12 ms | 4728 KB | Output is correct |
29 | Correct | 12 ms | 4576 KB | Output is correct |
30 | Correct | 16 ms | 4856 KB | Output is correct |
31 | Correct | 13 ms | 4856 KB | Output is correct |
32 | Correct | 13 ms | 4856 KB | Output is correct |
33 | Correct | 13 ms | 4856 KB | Output is correct |
34 | Correct | 14 ms | 4856 KB | Output is correct |
35 | Correct | 9 ms | 4344 KB | Output is correct |
36 | Correct | 9 ms | 4344 KB | Output is correct |
37 | Correct | 9 ms | 4344 KB | Output is correct |
38 | Correct | 8 ms | 4216 KB | Output is correct |
39 | Correct | 8 ms | 4188 KB | Output is correct |
40 | Correct | 17 ms | 5496 KB | Output is correct |
41 | Correct | 8 ms | 4216 KB | Output is correct |
42 | Correct | 17 ms | 5496 KB | Output is correct |
43 | Correct | 18 ms | 5404 KB | Output is correct |
44 | Correct | 5 ms | 3832 KB | Output is correct |
45 | Correct | 273 ms | 30740 KB | Output is correct |
46 | Correct | 117 ms | 15156 KB | Output is correct |
47 | Correct | 288 ms | 31136 KB | Output is correct |
48 | Correct | 265 ms | 30824 KB | Output is correct |
49 | Correct | 70 ms | 11848 KB | Output is correct |
50 | Correct | 255 ms | 29788 KB | Output is correct |
51 | Correct | 278 ms | 31128 KB | Output is correct |
52 | Correct | 63 ms | 11848 KB | Output is correct |
53 | Correct | 71 ms | 11836 KB | Output is correct |
54 | Correct | 17 ms | 4856 KB | Output is correct |
55 | Correct | 256 ms | 29764 KB | Output is correct |
56 | Correct | 43 ms | 8912 KB | Output is correct |
57 | Correct | 63 ms | 11760 KB | Output is correct |
58 | Correct | 94 ms | 14160 KB | Output is correct |
59 | Correct | 51 ms | 8944 KB | Output is correct |
60 | Correct | 44 ms | 8944 KB | Output is correct |
61 | Correct | 110 ms | 14268 KB | Output is correct |
62 | Correct | 80 ms | 11548 KB | Output is correct |
63 | Correct | 144 ms | 17592 KB | Output is correct |
64 | Correct | 44 ms | 8940 KB | Output is correct |
65 | Correct | 192 ms | 22264 KB | Output is correct |
66 | Correct | 70 ms | 11628 KB | Output is correct |
67 | Correct | 142 ms | 17608 KB | Output is correct |
68 | Correct | 181 ms | 21316 KB | Output is correct |
69 | Correct | 191 ms | 22356 KB | Output is correct |
70 | Correct | 69 ms | 11648 KB | Output is correct |
71 | Correct | 183 ms | 21408 KB | Output is correct |
72 | Correct | 131 ms | 17028 KB | Output is correct |
73 | Correct | 224 ms | 26188 KB | Output is correct |
74 | Correct | 70 ms | 11652 KB | Output is correct |
75 | Correct | 79 ms | 11784 KB | Output is correct |
76 | Correct | 137 ms | 17076 KB | Output is correct |
77 | Correct | 221 ms | 26124 KB | Output is correct |
78 | Correct | 109 ms | 14968 KB | Output is correct |
79 | Correct | 81 ms | 11716 KB | Output is correct |
80 | Correct | 37 ms | 7728 KB | Output is correct |
81 | Correct | 108 ms | 14960 KB | Output is correct |
82 | Correct | 159 ms | 20148 KB | Output is correct |
83 | Correct | 38 ms | 7832 KB | Output is correct |
84 | Correct | 160 ms | 20028 KB | Output is correct |