Submission #803044

# Submission time Handle Problem Language Result Execution time Memory
803044 2023-08-02T20:10:48 Z AmirElarbi Political Development (BOI17_politicaldevelopment) C++14
100 / 100
855 ms 308216 KB
#include<bits/stdc++.h>
typedef long long ll;
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pbds tree<pair<ll, ll>, null_type, less<pair<ll,ll>>,rb_tree_tag, tree_order_statistics_node_update>
using namespace __gnu_pbds;
#define speed ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
////////////////////Only Clear Code//////////////////////////
void usaco_problem(){
    freopen("milkvisits.in", "r", stdin);
    freopen("milkvisits.out", "w", stdout);
}
 
void init(){
    #ifndef ONLINE_JUDGE
 
freopen("input.txt", "r", stdin);
 
freopen("output.txt", "w", stdout);
 
#endif // ONLINE_JUDGE
}
 
const int mx = 5e4+5;
const int mxnd = mx*33;
const int LOG = 25;
const ll inf = 1e18;
const ll mod = 1e8;
 
vector<int> graph[mx];
 
int ans = 0;
 
vector<int> cur;
bool done[mx];
int n;

bitset<50005> bg[mx];

void solve(int k, bitset<50005> bs){
    if(ans == 10)return;
	ans = max(ans, k);
    if(k == 9){
        if(bs != 0) ans = 10;
        return;
    }
    ans = max(ans, k);
    if(k == 0){
        for(int i = 0; i < n;i++){ 
            cur.push_back(i);
            done[i] = 1;
            solve(k+1, bg[i]);
            done[i] = 0;
            cur.pop_back();
        }
        return;
    }
	bitset<50005> now = bs;
    while(now != 0){
		long unsigned int to = now._Find_first();
        now[to] = 0;
		solve(k+1, now & bg[to]);
		if(ans == 10) return;
	}
    /*
    for(int adj : graph[cur[0]]){
        if(done[adj])continue;
        bool take = 1;
        for(int x : cur){
            if(mp[x][adj] == 0)take = 0;
        }
        if(take){
            cur.push_back(adj);
            done[adj] = 1;
            solve(k+1);
            done[adj] = 0;
            cur.pop_back();
        }
    }*/
}
 
void run_case(){
    int k;cin >> n >> k;
    for(int i = 0; i < n;i++){
        int c;cin >> c;
        while(c--){
            int x;cin >> x;
            //graph[i].push_back(x);
            bg[i][x] = 1;
        }
    }
    ans = 0;
    solve(0,0);
    cout << ans << endl;
}
 
int main(){
    speed;
    int t = 1;
    //cin >> t;
    while(t--){
        run_case();
    }
}
 
/*
    NEVER GIVE UP!
    DOING SMTHNG IS BETTER THAN DOING NTHNG!!!
    Your Guide when stuck:
    - Continue keyword only after reading the whole input
    - Don't use memset with testcases
    - Check for corner cases(n=1, n=0)
    - Check where you declare n(Be careful of declaring it globally and in main)
*/

Compilation message

politicaldevelopment.cpp: In function 'void usaco_problem()':
politicaldevelopment.cpp:13:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |     freopen("milkvisits.in", "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
politicaldevelopment.cpp:14:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |     freopen("milkvisits.out", "w", stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
politicaldevelopment.cpp: In function 'void init()':
politicaldevelopment.cpp:20:8: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   20 | freopen("input.txt", "r", stdin);
      | ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
politicaldevelopment.cpp:22:8: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   22 | freopen("output.txt", "w", stdout);
      | ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1492 KB Output is correct
2 Correct 1 ms 1492 KB Output is correct
3 Correct 22 ms 22356 KB Output is correct
4 Correct 21 ms 21588 KB Output is correct
5 Correct 20 ms 21612 KB Output is correct
6 Correct 26 ms 21588 KB Output is correct
7 Correct 22 ms 21720 KB Output is correct
8 Correct 7 ms 1508 KB Output is correct
9 Correct 1 ms 1492 KB Output is correct
10 Correct 7 ms 1636 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1492 KB Output is correct
2 Correct 1 ms 1492 KB Output is correct
3 Correct 22 ms 22356 KB Output is correct
4 Correct 21 ms 21588 KB Output is correct
5 Correct 20 ms 21612 KB Output is correct
6 Correct 26 ms 21588 KB Output is correct
7 Correct 22 ms 21720 KB Output is correct
8 Correct 7 ms 1508 KB Output is correct
9 Correct 1 ms 1492 KB Output is correct
10 Correct 7 ms 1636 KB Output is correct
11 Correct 20 ms 21588 KB Output is correct
12 Correct 20 ms 21608 KB Output is correct
13 Correct 1 ms 1492 KB Output is correct
14 Correct 22 ms 21632 KB Output is correct
15 Correct 1 ms 1492 KB Output is correct
16 Correct 21 ms 21588 KB Output is correct
17 Correct 1 ms 1492 KB Output is correct
18 Correct 21 ms 21644 KB Output is correct
19 Correct 7 ms 1512 KB Output is correct
20 Correct 17 ms 21664 KB Output is correct
21 Correct 19 ms 21588 KB Output is correct
22 Correct 7 ms 1624 KB Output is correct
23 Correct 25 ms 22852 KB Output is correct
24 Correct 8 ms 1636 KB Output is correct
25 Correct 25 ms 22760 KB Output is correct
26 Correct 28 ms 22100 KB Output is correct
27 Correct 23 ms 22612 KB Output is correct
28 Correct 24 ms 21972 KB Output is correct
29 Correct 28 ms 22688 KB Output is correct
30 Correct 25 ms 22552 KB Output is correct
31 Correct 30 ms 22904 KB Output is correct
32 Correct 25 ms 22484 KB Output is correct
33 Correct 26 ms 22868 KB Output is correct
34 Correct 26 ms 23032 KB Output is correct
35 Correct 13 ms 12008 KB Output is correct
36 Correct 14 ms 11944 KB Output is correct
37 Correct 15 ms 11916 KB Output is correct
38 Correct 7 ms 6612 KB Output is correct
39 Correct 7 ms 6612 KB Output is correct
40 Correct 30 ms 23380 KB Output is correct
41 Correct 7 ms 6612 KB Output is correct
42 Correct 32 ms 23396 KB Output is correct
43 Correct 33 ms 23380 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 1620 KB Output is correct
2 Correct 1 ms 1620 KB Output is correct
3 Correct 2 ms 1620 KB Output is correct
4 Correct 1 ms 1620 KB Output is correct
5 Correct 1 ms 1620 KB Output is correct
6 Correct 1 ms 1620 KB Output is correct
7 Correct 1 ms 1620 KB Output is correct
8 Correct 2 ms 1620 KB Output is correct
9 Correct 1 ms 1632 KB Output is correct
10 Correct 1 ms 1620 KB Output is correct
11 Correct 806 ms 308216 KB Output is correct
12 Correct 2 ms 1620 KB Output is correct
13 Correct 805 ms 308060 KB Output is correct
14 Correct 1 ms 1620 KB Output is correct
15 Correct 807 ms 308052 KB Output is correct
16 Correct 855 ms 307996 KB Output is correct
17 Correct 809 ms 308144 KB Output is correct
18 Correct 799 ms 308144 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1492 KB Output is correct
2 Correct 1 ms 1492 KB Output is correct
3 Correct 22 ms 22356 KB Output is correct
4 Correct 21 ms 21588 KB Output is correct
5 Correct 20 ms 21612 KB Output is correct
6 Correct 26 ms 21588 KB Output is correct
7 Correct 22 ms 21720 KB Output is correct
8 Correct 7 ms 1508 KB Output is correct
9 Correct 1 ms 1492 KB Output is correct
10 Correct 7 ms 1636 KB Output is correct
11 Correct 20 ms 21588 KB Output is correct
12 Correct 20 ms 21608 KB Output is correct
13 Correct 1 ms 1492 KB Output is correct
14 Correct 22 ms 21632 KB Output is correct
15 Correct 1 ms 1492 KB Output is correct
16 Correct 21 ms 21588 KB Output is correct
17 Correct 1 ms 1492 KB Output is correct
18 Correct 21 ms 21644 KB Output is correct
19 Correct 7 ms 1512 KB Output is correct
20 Correct 17 ms 21664 KB Output is correct
21 Correct 19 ms 21588 KB Output is correct
22 Correct 7 ms 1624 KB Output is correct
23 Correct 25 ms 22852 KB Output is correct
24 Correct 8 ms 1636 KB Output is correct
25 Correct 25 ms 22760 KB Output is correct
26 Correct 28 ms 22100 KB Output is correct
27 Correct 23 ms 22612 KB Output is correct
28 Correct 24 ms 21972 KB Output is correct
29 Correct 28 ms 22688 KB Output is correct
30 Correct 25 ms 22552 KB Output is correct
31 Correct 30 ms 22904 KB Output is correct
32 Correct 25 ms 22484 KB Output is correct
33 Correct 26 ms 22868 KB Output is correct
34 Correct 26 ms 23032 KB Output is correct
35 Correct 13 ms 12008 KB Output is correct
36 Correct 14 ms 11944 KB Output is correct
37 Correct 15 ms 11916 KB Output is correct
38 Correct 7 ms 6612 KB Output is correct
39 Correct 7 ms 6612 KB Output is correct
40 Correct 30 ms 23380 KB Output is correct
41 Correct 7 ms 6612 KB Output is correct
42 Correct 32 ms 23396 KB Output is correct
43 Correct 33 ms 23380 KB Output is correct
44 Correct 17 ms 24148 KB Output is correct
45 Correct 1 ms 1620 KB Output is correct
46 Correct 33 ms 23292 KB Output is correct
47 Correct 55 ms 24068 KB Output is correct
48 Correct 32 ms 23124 KB Output is correct
49 Correct 52 ms 24080 KB Output is correct
50 Correct 49 ms 24020 KB Output is correct
51 Correct 98 ms 24684 KB Output is correct
52 Correct 21 ms 21664 KB Output is correct
53 Correct 86 ms 24556 KB Output is correct
54 Correct 19 ms 24852 KB Output is correct
55 Correct 22 ms 21608 KB Output is correct
56 Correct 21 ms 21588 KB Output is correct
57 Correct 7 ms 1492 KB Output is correct
58 Correct 97 ms 24488 KB Output is correct
59 Correct 75 ms 23704 KB Output is correct
60 Correct 22 ms 21632 KB Output is correct
61 Correct 75 ms 23632 KB Output is correct
62 Correct 75 ms 23636 KB Output is correct
63 Correct 127 ms 24316 KB Output is correct
64 Correct 508 ms 24316 KB Output is correct
65 Correct 31 ms 23228 KB Output is correct
66 Correct 73 ms 23532 KB Output is correct
67 Correct 17 ms 24148 KB Output is correct
68 Correct 496 ms 24148 KB Output is correct
69 Correct 32 ms 23176 KB Output is correct
70 Correct 70 ms 23932 KB Output is correct
71 Correct 27 ms 24148 KB Output is correct
72 Correct 173 ms 24276 KB Output is correct
73 Correct 22 ms 22484 KB Output is correct
74 Correct 70 ms 24040 KB Output is correct
75 Correct 170 ms 24248 KB Output is correct
76 Correct 37 ms 23636 KB Output is correct
77 Correct 66 ms 24460 KB Output is correct
78 Correct 26 ms 22700 KB Output is correct
79 Correct 28 ms 12352 KB Output is correct
80 Correct 48 ms 23560 KB Output is correct
81 Correct 66 ms 24404 KB Output is correct
82 Correct 7 ms 6612 KB Output is correct
83 Correct 30 ms 12396 KB Output is correct
84 Correct 56 ms 24312 KB Output is correct
85 Correct 7 ms 6612 KB Output is correct
86 Correct 55 ms 24424 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1492 KB Output is correct
2 Correct 1 ms 1492 KB Output is correct
3 Correct 22 ms 22356 KB Output is correct
4 Correct 21 ms 21588 KB Output is correct
5 Correct 20 ms 21612 KB Output is correct
6 Correct 26 ms 21588 KB Output is correct
7 Correct 22 ms 21720 KB Output is correct
8 Correct 7 ms 1508 KB Output is correct
9 Correct 1 ms 1492 KB Output is correct
10 Correct 7 ms 1636 KB Output is correct
11 Correct 20 ms 21588 KB Output is correct
12 Correct 20 ms 21608 KB Output is correct
13 Correct 1 ms 1492 KB Output is correct
14 Correct 22 ms 21632 KB Output is correct
15 Correct 1 ms 1492 KB Output is correct
16 Correct 21 ms 21588 KB Output is correct
17 Correct 1 ms 1492 KB Output is correct
18 Correct 21 ms 21644 KB Output is correct
19 Correct 7 ms 1512 KB Output is correct
20 Correct 17 ms 21664 KB Output is correct
21 Correct 19 ms 21588 KB Output is correct
22 Correct 7 ms 1624 KB Output is correct
23 Correct 25 ms 22852 KB Output is correct
24 Correct 8 ms 1636 KB Output is correct
25 Correct 25 ms 22760 KB Output is correct
26 Correct 28 ms 22100 KB Output is correct
27 Correct 23 ms 22612 KB Output is correct
28 Correct 24 ms 21972 KB Output is correct
29 Correct 28 ms 22688 KB Output is correct
30 Correct 25 ms 22552 KB Output is correct
31 Correct 30 ms 22904 KB Output is correct
32 Correct 25 ms 22484 KB Output is correct
33 Correct 26 ms 22868 KB Output is correct
34 Correct 26 ms 23032 KB Output is correct
35 Correct 13 ms 12008 KB Output is correct
36 Correct 14 ms 11944 KB Output is correct
37 Correct 15 ms 11916 KB Output is correct
38 Correct 7 ms 6612 KB Output is correct
39 Correct 7 ms 6612 KB Output is correct
40 Correct 30 ms 23380 KB Output is correct
41 Correct 7 ms 6612 KB Output is correct
42 Correct 32 ms 23396 KB Output is correct
43 Correct 33 ms 23380 KB Output is correct
44 Correct 1 ms 1620 KB Output is correct
45 Correct 571 ms 302332 KB Output is correct
46 Correct 385 ms 275132 KB Output is correct
47 Correct 567 ms 301052 KB Output is correct
48 Correct 569 ms 302296 KB Output is correct
49 Correct 208 ms 202140 KB Output is correct
50 Correct 561 ms 307708 KB Output is correct
51 Correct 578 ms 300860 KB Output is correct
52 Correct 228 ms 188796 KB Output is correct
53 Correct 211 ms 202148 KB Output is correct
54 Correct 67 ms 2060 KB Output is correct
55 Correct 560 ms 307708 KB Output is correct
56 Correct 173 ms 188024 KB Output is correct
57 Correct 227 ms 189808 KB Output is correct
58 Correct 566 ms 288596 KB Output is correct
59 Correct 186 ms 188104 KB Output is correct
60 Correct 199 ms 188016 KB Output is correct
61 Correct 562 ms 288852 KB Output is correct
62 Correct 318 ms 259632 KB Output is correct
63 Correct 399 ms 282572 KB Output is correct
64 Correct 177 ms 187960 KB Output is correct
65 Correct 559 ms 292732 KB Output is correct
66 Correct 317 ms 260704 KB Output is correct
67 Correct 402 ms 282164 KB Output is correct
68 Correct 449 ms 290736 KB Output is correct
69 Correct 510 ms 291700 KB Output is correct
70 Correct 265 ms 260136 KB Output is correct
71 Correct 459 ms 291300 KB Output is correct
72 Correct 342 ms 272844 KB Output is correct
73 Correct 514 ms 303772 KB Output is correct
74 Correct 279 ms 260380 KB Output is correct
75 Correct 187 ms 141784 KB Output is correct
76 Correct 352 ms 265860 KB Output is correct
77 Correct 511 ms 303668 KB Output is correct
78 Correct 230 ms 147396 KB Output is correct
79 Correct 188 ms 142064 KB Output is correct
80 Correct 84 ms 58028 KB Output is correct
81 Correct 239 ms 147376 KB Output is correct
82 Correct 426 ms 299852 KB Output is correct
83 Correct 77 ms 58068 KB Output is correct
84 Correct 424 ms 300180 KB Output is correct