Submission #1115891

# Submission time Handle Problem Language Result Execution time Memory
1115891 2024-11-21T03:38:30 Z vjudge1 Political Development (BOI17_politicaldevelopment) C++17
100 / 100
652 ms 333040 KB
#include <bits/stdc++.h>
using namespace std;
 
#define ll int
#define pll pair<long long, long long>
#define pb push_back
#define F first
#define S second  
#define all(x) (x).begin(), (x).end()
 
const ll N = 1e6 + 100;
const ll inf = 1e18;
const ll mod = 1e9 + 7;
const ll block = 1e3;
bitset<50005>b[50005], cur;
ll n,k;    
void to_thic_cau(){
    cin >> n >> k;
    vector<vector<ll>>prv;
    for(ll i = 0; i < n;i++){
        prv.pb({i});   
        ll sz; cin >> sz;
        while(sz--){
            ll v; cin >> v;
            b[min(i, v)][max(i, v)] = 1;
        }
    }
    for(int i = 2; i <= k + 1;i++){
        vector<vector<ll>>nxt;
        for(auto vec : prv){
            cur = b[vec[0]];
            for(int j = 1; j < vec.size();j++) cur &= b[vec[j]];
            for(int j = cur._Find_first(); j < n; j = cur._Find_next(j)){
                vector<ll>tmp = vec;
                tmp.pb(j);
                nxt.pb(tmp);
            }
        }
        prv.clear(); prv = nxt;
        if(!prv.size()){
            cout << i - 1 << "\n";
            return;
        } 
    }
}

signed main()
{   
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int tc = 1;   
    //cin >> tc;
    while(tc--) to_thic_cau();
}

Compilation message

politicaldevelopment.cpp:12:16: warning: overflow in conversion from 'double' to 'int' changes value from '1.0e+18' to '2147483647' [-Woverflow]
   12 | const ll inf = 1e18;
      |                ^~~~
politicaldevelopment.cpp: In function 'void to_thic_cau()':
politicaldevelopment.cpp:32:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |             for(int j = 1; j < vec.size();j++) cur &= b[vec[j]];
      |                            ~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 504 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 16 ms 31824 KB Output is correct
4 Correct 12 ms 11516 KB Output is correct
5 Correct 12 ms 13392 KB Output is correct
6 Correct 14 ms 31824 KB Output is correct
7 Correct 14 ms 31932 KB Output is correct
8 Correct 5 ms 848 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 5 ms 2896 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 504 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 16 ms 31824 KB Output is correct
4 Correct 12 ms 11516 KB Output is correct
5 Correct 12 ms 13392 KB Output is correct
6 Correct 14 ms 31824 KB Output is correct
7 Correct 14 ms 31932 KB Output is correct
8 Correct 5 ms 848 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 5 ms 2896 KB Output is correct
11 Correct 11 ms 9296 KB Output is correct
12 Correct 12 ms 11344 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 12 ms 19536 KB Output is correct
15 Correct 1 ms 504 KB Output is correct
16 Correct 14 ms 31824 KB Output is correct
17 Correct 1 ms 336 KB Output is correct
18 Correct 14 ms 31992 KB Output is correct
19 Correct 5 ms 1016 KB Output is correct
20 Correct 13 ms 31700 KB Output is correct
21 Correct 12 ms 31700 KB Output is correct
22 Correct 5 ms 3072 KB Output is correct
23 Correct 18 ms 32016 KB Output is correct
24 Correct 5 ms 2896 KB Output is correct
25 Correct 18 ms 32032 KB Output is correct
26 Correct 17 ms 31824 KB Output is correct
27 Correct 16 ms 31824 KB Output is correct
28 Correct 16 ms 32076 KB Output is correct
29 Correct 17 ms 31916 KB Output is correct
30 Correct 18 ms 32248 KB Output is correct
31 Correct 18 ms 32336 KB Output is correct
32 Correct 18 ms 32248 KB Output is correct
33 Correct 17 ms 32080 KB Output is correct
34 Correct 20 ms 32080 KB Output is correct
35 Correct 11 ms 17232 KB Output is correct
36 Correct 9 ms 17232 KB Output is correct
37 Correct 9 ms 17232 KB Output is correct
38 Correct 6 ms 9204 KB Output is correct
39 Correct 6 ms 9040 KB Output is correct
40 Correct 22 ms 32412 KB Output is correct
41 Correct 6 ms 9044 KB Output is correct
42 Correct 26 ms 32584 KB Output is correct
43 Correct 22 ms 32396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 848 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 491 ms 330220 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Correct 469 ms 329976 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 466 ms 326776 KB Output is correct
16 Correct 477 ms 333040 KB Output is correct
17 Correct 470 ms 333040 KB Output is correct
18 Correct 492 ms 333036 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 504 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 16 ms 31824 KB Output is correct
4 Correct 12 ms 11516 KB Output is correct
5 Correct 12 ms 13392 KB Output is correct
6 Correct 14 ms 31824 KB Output is correct
7 Correct 14 ms 31932 KB Output is correct
8 Correct 5 ms 848 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 5 ms 2896 KB Output is correct
11 Correct 11 ms 9296 KB Output is correct
12 Correct 12 ms 11344 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 12 ms 19536 KB Output is correct
15 Correct 1 ms 504 KB Output is correct
16 Correct 14 ms 31824 KB Output is correct
17 Correct 1 ms 336 KB Output is correct
18 Correct 14 ms 31992 KB Output is correct
19 Correct 5 ms 1016 KB Output is correct
20 Correct 13 ms 31700 KB Output is correct
21 Correct 12 ms 31700 KB Output is correct
22 Correct 5 ms 3072 KB Output is correct
23 Correct 18 ms 32016 KB Output is correct
24 Correct 5 ms 2896 KB Output is correct
25 Correct 18 ms 32032 KB Output is correct
26 Correct 17 ms 31824 KB Output is correct
27 Correct 16 ms 31824 KB Output is correct
28 Correct 16 ms 32076 KB Output is correct
29 Correct 17 ms 31916 KB Output is correct
30 Correct 18 ms 32248 KB Output is correct
31 Correct 18 ms 32336 KB Output is correct
32 Correct 18 ms 32248 KB Output is correct
33 Correct 17 ms 32080 KB Output is correct
34 Correct 20 ms 32080 KB Output is correct
35 Correct 11 ms 17232 KB Output is correct
36 Correct 9 ms 17232 KB Output is correct
37 Correct 9 ms 17232 KB Output is correct
38 Correct 6 ms 9204 KB Output is correct
39 Correct 6 ms 9040 KB Output is correct
40 Correct 22 ms 32412 KB Output is correct
41 Correct 6 ms 9044 KB Output is correct
42 Correct 26 ms 32584 KB Output is correct
43 Correct 22 ms 32396 KB Output is correct
44 Correct 652 ms 43584 KB Output is correct
45 Correct 1 ms 336 KB Output is correct
46 Correct 24 ms 32396 KB Output is correct
47 Correct 38 ms 33712 KB Output is correct
48 Correct 24 ms 32396 KB Output is correct
49 Correct 38 ms 33528 KB Output is correct
50 Correct 40 ms 33544 KB Output is correct
51 Correct 73 ms 35844 KB Output is correct
52 Correct 11 ms 3152 KB Output is correct
53 Correct 72 ms 36428 KB Output is correct
54 Correct 103 ms 36348 KB Output is correct
55 Correct 17 ms 31824 KB Output is correct
56 Correct 12 ms 3152 KB Output is correct
57 Correct 4 ms 848 KB Output is correct
58 Correct 72 ms 32260 KB Output is correct
59 Correct 57 ms 32808 KB Output is correct
60 Correct 17 ms 31824 KB Output is correct
61 Correct 56 ms 32800 KB Output is correct
62 Correct 68 ms 32808 KB Output is correct
63 Correct 650 ms 43588 KB Output is correct
64 Correct 335 ms 37008 KB Output is correct
65 Correct 21 ms 32564 KB Output is correct
66 Correct 51 ms 32808 KB Output is correct
67 Correct 181 ms 34056 KB Output is correct
68 Correct 331 ms 37140 KB Output is correct
69 Correct 21 ms 32396 KB Output is correct
70 Correct 51 ms 33288 KB Output is correct
71 Correct 180 ms 34056 KB Output is correct
72 Correct 109 ms 33800 KB Output is correct
73 Correct 14 ms 31824 KB Output is correct
74 Correct 61 ms 33288 KB Output is correct
75 Correct 113 ms 33800 KB Output is correct
76 Correct 29 ms 32908 KB Output is correct
77 Correct 52 ms 34568 KB Output is correct
78 Correct 16 ms 31992 KB Output is correct
79 Correct 25 ms 18572 KB Output is correct
80 Correct 29 ms 33080 KB Output is correct
81 Correct 53 ms 34568 KB Output is correct
82 Correct 7 ms 9040 KB Output is correct
83 Correct 26 ms 18572 KB Output is correct
84 Correct 44 ms 33800 KB Output is correct
85 Correct 6 ms 9208 KB Output is correct
86 Correct 43 ms 34108 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 504 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 16 ms 31824 KB Output is correct
4 Correct 12 ms 11516 KB Output is correct
5 Correct 12 ms 13392 KB Output is correct
6 Correct 14 ms 31824 KB Output is correct
7 Correct 14 ms 31932 KB Output is correct
8 Correct 5 ms 848 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 5 ms 2896 KB Output is correct
11 Correct 11 ms 9296 KB Output is correct
12 Correct 12 ms 11344 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 12 ms 19536 KB Output is correct
15 Correct 1 ms 504 KB Output is correct
16 Correct 14 ms 31824 KB Output is correct
17 Correct 1 ms 336 KB Output is correct
18 Correct 14 ms 31992 KB Output is correct
19 Correct 5 ms 1016 KB Output is correct
20 Correct 13 ms 31700 KB Output is correct
21 Correct 12 ms 31700 KB Output is correct
22 Correct 5 ms 3072 KB Output is correct
23 Correct 18 ms 32016 KB Output is correct
24 Correct 5 ms 2896 KB Output is correct
25 Correct 18 ms 32032 KB Output is correct
26 Correct 17 ms 31824 KB Output is correct
27 Correct 16 ms 31824 KB Output is correct
28 Correct 16 ms 32076 KB Output is correct
29 Correct 17 ms 31916 KB Output is correct
30 Correct 18 ms 32248 KB Output is correct
31 Correct 18 ms 32336 KB Output is correct
32 Correct 18 ms 32248 KB Output is correct
33 Correct 17 ms 32080 KB Output is correct
34 Correct 20 ms 32080 KB Output is correct
35 Correct 11 ms 17232 KB Output is correct
36 Correct 9 ms 17232 KB Output is correct
37 Correct 9 ms 17232 KB Output is correct
38 Correct 6 ms 9204 KB Output is correct
39 Correct 6 ms 9040 KB Output is correct
40 Correct 22 ms 32412 KB Output is correct
41 Correct 6 ms 9044 KB Output is correct
42 Correct 26 ms 32584 KB Output is correct
43 Correct 22 ms 32396 KB Output is correct
44 Correct 1 ms 336 KB Output is correct
45 Correct 368 ms 284396 KB Output is correct
46 Correct 234 ms 286712 KB Output is correct
47 Correct 357 ms 298228 KB Output is correct
48 Correct 360 ms 297972 KB Output is correct
49 Correct 146 ms 199164 KB Output is correct
50 Correct 426 ms 304352 KB Output is correct
51 Correct 357 ms 305640 KB Output is correct
52 Correct 169 ms 290304 KB Output is correct
53 Correct 160 ms 215596 KB Output is correct
54 Correct 44 ms 3580 KB Output is correct
55 Correct 403 ms 315888 KB Output is correct
56 Correct 139 ms 271308 KB Output is correct
57 Correct 162 ms 278244 KB Output is correct
58 Correct 355 ms 284408 KB Output is correct
59 Correct 131 ms 290300 KB Output is correct
60 Correct 130 ms 296188 KB Output is correct
61 Correct 358 ms 291320 KB Output is correct
62 Correct 216 ms 288764 KB Output is correct
63 Correct 272 ms 296364 KB Output is correct
64 Correct 133 ms 288508 KB Output is correct
65 Correct 312 ms 290040 KB Output is correct
66 Correct 213 ms 283132 KB Output is correct
67 Correct 253 ms 291320 KB Output is correct
68 Correct 255 ms 297208 KB Output is correct
69 Correct 292 ms 299400 KB Output is correct
70 Correct 157 ms 288508 KB Output is correct
71 Correct 256 ms 292088 KB Output is correct
72 Correct 219 ms 287736 KB Output is correct
73 Correct 280 ms 291064 KB Output is correct
74 Correct 157 ms 283132 KB Output is correct
75 Correct 111 ms 160276 KB Output is correct
76 Correct 218 ms 280824 KB Output is correct
77 Correct 313 ms 295160 KB Output is correct
78 Correct 149 ms 162168 KB Output is correct
79 Correct 124 ms 158204 KB Output is correct
80 Correct 61 ms 79396 KB Output is correct
81 Correct 153 ms 162044 KB Output is correct
82 Correct 273 ms 266996 KB Output is correct
83 Correct 58 ms 81320 KB Output is correct
84 Correct 259 ms 263328 KB Output is correct