Submission #803051

# Submission time Handle Problem Language Result Execution time Memory
803051 2023-08-02T20:16:49 Z YassineBenYounes Political Development (BOI17_politicaldevelopment) C++17
100 / 100
838 ms 307732 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<50000> bg[mx];

void solve(int k, bitset<50000> bs){
    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<50000> 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 1504 KB Output is correct
2 Correct 1 ms 1492 KB Output is correct
3 Correct 27 ms 22300 KB Output is correct
4 Correct 20 ms 21612 KB Output is correct
5 Correct 20 ms 21596 KB Output is correct
6 Correct 25 ms 21716 KB Output is correct
7 Correct 21 ms 21588 KB Output is correct
8 Correct 7 ms 1492 KB Output is correct
9 Correct 1 ms 1492 KB Output is correct
10 Correct 7 ms 1620 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1504 KB Output is correct
2 Correct 1 ms 1492 KB Output is correct
3 Correct 27 ms 22300 KB Output is correct
4 Correct 20 ms 21612 KB Output is correct
5 Correct 20 ms 21596 KB Output is correct
6 Correct 25 ms 21716 KB Output is correct
7 Correct 21 ms 21588 KB Output is correct
8 Correct 7 ms 1492 KB Output is correct
9 Correct 1 ms 1492 KB Output is correct
10 Correct 7 ms 1620 KB Output is correct
11 Correct 20 ms 21544 KB Output is correct
12 Correct 21 ms 21620 KB Output is correct
13 Correct 1 ms 1492 KB Output is correct
14 Correct 20 ms 21588 KB Output is correct
15 Correct 1 ms 1492 KB Output is correct
16 Correct 22 ms 21636 KB Output is correct
17 Correct 1 ms 1492 KB Output is correct
18 Correct 22 ms 21648 KB Output is correct
19 Correct 7 ms 1492 KB Output is correct
20 Correct 18 ms 21612 KB Output is correct
21 Correct 18 ms 21632 KB Output is correct
22 Correct 8 ms 1620 KB Output is correct
23 Correct 25 ms 22748 KB Output is correct
24 Correct 7 ms 1620 KB Output is correct
25 Correct 25 ms 22760 KB Output is correct
26 Correct 24 ms 21972 KB Output is correct
27 Correct 22 ms 22620 KB Output is correct
28 Correct 23 ms 21844 KB Output is correct
29 Correct 23 ms 22660 KB Output is correct
30 Correct 25 ms 22356 KB Output is correct
31 Correct 25 ms 22900 KB Output is correct
32 Correct 24 ms 22480 KB Output is correct
33 Correct 26 ms 22856 KB Output is correct
34 Correct 32 ms 22976 KB Output is correct
35 Correct 13 ms 11872 KB Output is correct
36 Correct 12 ms 11888 KB Output is correct
37 Correct 12 ms 11880 KB Output is correct
38 Correct 8 ms 6484 KB Output is correct
39 Correct 7 ms 6532 KB Output is correct
40 Correct 32 ms 23348 KB Output is correct
41 Correct 7 ms 6484 KB Output is correct
42 Correct 32 ms 23284 KB Output is correct
43 Correct 31 ms 23252 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 1584 KB Output is correct
2 Correct 1 ms 1620 KB Output is correct
3 Correct 1 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 1 ms 1620 KB Output is correct
9 Correct 1 ms 1620 KB Output is correct
10 Correct 1 ms 1620 KB Output is correct
11 Correct 810 ms 307552 KB Output is correct
12 Correct 1 ms 1620 KB Output is correct
13 Correct 813 ms 307720 KB Output is correct
14 Correct 1 ms 1620 KB Output is correct
15 Correct 818 ms 307620 KB Output is correct
16 Correct 838 ms 307636 KB Output is correct
17 Correct 807 ms 307688 KB Output is correct
18 Correct 813 ms 307732 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1504 KB Output is correct
2 Correct 1 ms 1492 KB Output is correct
3 Correct 27 ms 22300 KB Output is correct
4 Correct 20 ms 21612 KB Output is correct
5 Correct 20 ms 21596 KB Output is correct
6 Correct 25 ms 21716 KB Output is correct
7 Correct 21 ms 21588 KB Output is correct
8 Correct 7 ms 1492 KB Output is correct
9 Correct 1 ms 1492 KB Output is correct
10 Correct 7 ms 1620 KB Output is correct
11 Correct 20 ms 21544 KB Output is correct
12 Correct 21 ms 21620 KB Output is correct
13 Correct 1 ms 1492 KB Output is correct
14 Correct 20 ms 21588 KB Output is correct
15 Correct 1 ms 1492 KB Output is correct
16 Correct 22 ms 21636 KB Output is correct
17 Correct 1 ms 1492 KB Output is correct
18 Correct 22 ms 21648 KB Output is correct
19 Correct 7 ms 1492 KB Output is correct
20 Correct 18 ms 21612 KB Output is correct
21 Correct 18 ms 21632 KB Output is correct
22 Correct 8 ms 1620 KB Output is correct
23 Correct 25 ms 22748 KB Output is correct
24 Correct 7 ms 1620 KB Output is correct
25 Correct 25 ms 22760 KB Output is correct
26 Correct 24 ms 21972 KB Output is correct
27 Correct 22 ms 22620 KB Output is correct
28 Correct 23 ms 21844 KB Output is correct
29 Correct 23 ms 22660 KB Output is correct
30 Correct 25 ms 22356 KB Output is correct
31 Correct 25 ms 22900 KB Output is correct
32 Correct 24 ms 22480 KB Output is correct
33 Correct 26 ms 22856 KB Output is correct
34 Correct 32 ms 22976 KB Output is correct
35 Correct 13 ms 11872 KB Output is correct
36 Correct 12 ms 11888 KB Output is correct
37 Correct 12 ms 11880 KB Output is correct
38 Correct 8 ms 6484 KB Output is correct
39 Correct 7 ms 6532 KB Output is correct
40 Correct 32 ms 23348 KB Output is correct
41 Correct 7 ms 6484 KB Output is correct
42 Correct 32 ms 23284 KB Output is correct
43 Correct 31 ms 23252 KB Output is correct
44 Correct 47 ms 24020 KB Output is correct
45 Correct 1 ms 1620 KB Output is correct
46 Correct 31 ms 23160 KB Output is correct
47 Correct 51 ms 23832 KB Output is correct
48 Correct 31 ms 23060 KB Output is correct
49 Correct 51 ms 23892 KB Output is correct
50 Correct 50 ms 23856 KB Output is correct
51 Correct 100 ms 24300 KB Output is correct
52 Correct 21 ms 21528 KB Output is correct
53 Correct 87 ms 24264 KB Output is correct
54 Correct 30 ms 24732 KB Output is correct
55 Correct 21 ms 21588 KB Output is correct
56 Correct 21 ms 21612 KB Output is correct
57 Correct 7 ms 1492 KB Output is correct
58 Correct 92 ms 24104 KB Output is correct
59 Correct 76 ms 23596 KB Output is correct
60 Correct 24 ms 21588 KB Output is correct
61 Correct 75 ms 23524 KB Output is correct
62 Correct 75 ms 23520 KB Output is correct
63 Correct 163 ms 24124 KB Output is correct
64 Correct 513 ms 24012 KB Output is correct
65 Correct 31 ms 23124 KB Output is correct
66 Correct 74 ms 23368 KB Output is correct
67 Correct 25 ms 24044 KB Output is correct
68 Correct 508 ms 23968 KB Output is correct
69 Correct 30 ms 23096 KB Output is correct
70 Correct 75 ms 23736 KB Output is correct
71 Correct 37 ms 24004 KB Output is correct
72 Correct 173 ms 24028 KB Output is correct
73 Correct 23 ms 22484 KB Output is correct
74 Correct 73 ms 23864 KB Output is correct
75 Correct 174 ms 24020 KB Output is correct
76 Correct 37 ms 23508 KB Output is correct
77 Correct 72 ms 24148 KB Output is correct
78 Correct 22 ms 22612 KB Output is correct
79 Correct 29 ms 12244 KB Output is correct
80 Correct 37 ms 23380 KB Output is correct
81 Correct 67 ms 24148 KB Output is correct
82 Correct 7 ms 6628 KB Output is correct
83 Correct 29 ms 12244 KB Output is correct
84 Correct 56 ms 24092 KB Output is correct
85 Correct 7 ms 6484 KB Output is correct
86 Correct 56 ms 24148 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1504 KB Output is correct
2 Correct 1 ms 1492 KB Output is correct
3 Correct 27 ms 22300 KB Output is correct
4 Correct 20 ms 21612 KB Output is correct
5 Correct 20 ms 21596 KB Output is correct
6 Correct 25 ms 21716 KB Output is correct
7 Correct 21 ms 21588 KB Output is correct
8 Correct 7 ms 1492 KB Output is correct
9 Correct 1 ms 1492 KB Output is correct
10 Correct 7 ms 1620 KB Output is correct
11 Correct 20 ms 21544 KB Output is correct
12 Correct 21 ms 21620 KB Output is correct
13 Correct 1 ms 1492 KB Output is correct
14 Correct 20 ms 21588 KB Output is correct
15 Correct 1 ms 1492 KB Output is correct
16 Correct 22 ms 21636 KB Output is correct
17 Correct 1 ms 1492 KB Output is correct
18 Correct 22 ms 21648 KB Output is correct
19 Correct 7 ms 1492 KB Output is correct
20 Correct 18 ms 21612 KB Output is correct
21 Correct 18 ms 21632 KB Output is correct
22 Correct 8 ms 1620 KB Output is correct
23 Correct 25 ms 22748 KB Output is correct
24 Correct 7 ms 1620 KB Output is correct
25 Correct 25 ms 22760 KB Output is correct
26 Correct 24 ms 21972 KB Output is correct
27 Correct 22 ms 22620 KB Output is correct
28 Correct 23 ms 21844 KB Output is correct
29 Correct 23 ms 22660 KB Output is correct
30 Correct 25 ms 22356 KB Output is correct
31 Correct 25 ms 22900 KB Output is correct
32 Correct 24 ms 22480 KB Output is correct
33 Correct 26 ms 22856 KB Output is correct
34 Correct 32 ms 22976 KB Output is correct
35 Correct 13 ms 11872 KB Output is correct
36 Correct 12 ms 11888 KB Output is correct
37 Correct 12 ms 11880 KB Output is correct
38 Correct 8 ms 6484 KB Output is correct
39 Correct 7 ms 6532 KB Output is correct
40 Correct 32 ms 23348 KB Output is correct
41 Correct 7 ms 6484 KB Output is correct
42 Correct 32 ms 23284 KB Output is correct
43 Correct 31 ms 23252 KB Output is correct
44 Correct 1 ms 1620 KB Output is correct
45 Correct 575 ms 302084 KB Output is correct
46 Correct 357 ms 275012 KB Output is correct
47 Correct 576 ms 300932 KB Output is correct
48 Correct 584 ms 302196 KB Output is correct
49 Correct 213 ms 202104 KB Output is correct
50 Correct 554 ms 307640 KB Output is correct
51 Correct 573 ms 300884 KB Output is correct
52 Correct 231 ms 188748 KB Output is correct
53 Correct 218 ms 202060 KB Output is correct
54 Correct 65 ms 2124 KB Output is correct
55 Correct 569 ms 307612 KB Output is correct
56 Correct 189 ms 188108 KB Output is correct
57 Correct 250 ms 189644 KB Output is correct
58 Correct 587 ms 288588 KB Output is correct
59 Correct 182 ms 187980 KB Output is correct
60 Correct 183 ms 188008 KB Output is correct
61 Correct 582 ms 288900 KB Output is correct
62 Correct 328 ms 259716 KB Output is correct
63 Correct 415 ms 282648 KB Output is correct
64 Correct 181 ms 187956 KB Output is correct
65 Correct 541 ms 292744 KB Output is correct
66 Correct 341 ms 260740 KB Output is correct
67 Correct 408 ms 282292 KB Output is correct
68 Correct 467 ms 290672 KB Output is correct
69 Correct 535 ms 291688 KB Output is correct
70 Correct 277 ms 260024 KB Output is correct
71 Correct 475 ms 291392 KB Output is correct
72 Correct 359 ms 272896 KB Output is correct
73 Correct 533 ms 303748 KB Output is correct
74 Correct 277 ms 260300 KB Output is correct
75 Correct 202 ms 141800 KB Output is correct
76 Correct 367 ms 265924 KB Output is correct
77 Correct 530 ms 303636 KB Output is correct
78 Correct 245 ms 147376 KB Output is correct
79 Correct 198 ms 142128 KB Output is correct
80 Correct 93 ms 58156 KB Output is correct
81 Correct 242 ms 147312 KB Output is correct
82 Correct 439 ms 299844 KB Output is correct
83 Correct 87 ms 58184 KB Output is correct
84 Correct 434 ms 300044 KB Output is correct