# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
783042 | 2023-07-14T14:29:21 Z | 1075508020060209tc | Political Development (BOI17_politicaldevelopment) | C++14 | 14 ms | 24916 KB |
#include<bits/stdc++.h> using namespace std; //#define int long long #define X first #define Y second int n;int K; set<int>st[50100]; bitset<50100>tbl[50100]; signed main(){ cin.tie(0); ios_base::sync_with_stdio(0); cin>>n>>K; for(int i=0;i<n;i++){ int d; cin>>d; for(int j=1;j<=d;j++){ int v; cin>>v; st[i].insert(v); tbl[i][v]=1; } tbl[i][i]=1; st[i].insert(i); } int ans=1; for(int i=0;i<n;i++){ vector<int>vc; for(auto it=st[i].begin();it!=st[i].end();it++){ vc.push_back(*it); } for(int A=0;A<(1<<vc.size());A++){ if(__builtin_popcount(A)<=ans){continue;} if(__builtin_popcount(A)>K){continue;} int ok=1; // cout<<A<<"A\n"; bitset<50100>tmp; for(int j=0;j<vc.size();j++){ tmp[vc[j]]=1; } for(int j=0;j<vc.size();j++){ // cout<<vc[j]<<" "<<ok<<endl;; if(!ok){break;} if(((A&(1<<j))!=0)){ if(((tbl[vc[j]]&tmp)!=tmp) ){ ok=0; } } } //cout<<ok<<endl; if((ok&&(__builtin_popcount(A)>ans)) ){ ans=__builtin_popcount(A); } } } cout<<ans<<endl; //return 0; /* for(int i=0;i<ans.size();i++){ cout<<ans[i]<<" "; }*/ }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 2644 KB | Output is correct |
2 | Correct | 1 ms | 2688 KB | Output is correct |
3 | Correct | 12 ms | 24916 KB | Output is correct |
4 | Correct | 14 ms | 24404 KB | Output is correct |
5 | Correct | 11 ms | 24336 KB | Output is correct |
6 | Correct | 12 ms | 24532 KB | Output is correct |
7 | Correct | 11 ms | 24432 KB | Output is correct |
8 | Correct | 9 ms | 22948 KB | Output is correct |
9 | Correct | 1 ms | 2644 KB | Output is correct |
10 | Correct | 9 ms | 22920 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 2644 KB | Output is correct |
2 | Correct | 1 ms | 2688 KB | Output is correct |
3 | Correct | 12 ms | 24916 KB | Output is correct |
4 | Correct | 14 ms | 24404 KB | Output is correct |
5 | Correct | 11 ms | 24336 KB | Output is correct |
6 | Correct | 12 ms | 24532 KB | Output is correct |
7 | Correct | 11 ms | 24432 KB | Output is correct |
8 | Correct | 9 ms | 22948 KB | Output is correct |
9 | Correct | 1 ms | 2644 KB | Output is correct |
10 | Correct | 9 ms | 22920 KB | Output is correct |
11 | Correct | 11 ms | 24464 KB | Output is correct |
12 | Correct | 11 ms | 24352 KB | Output is correct |
13 | Incorrect | 1 ms | 2644 KB | Output isn't correct |
14 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 9 ms | 22920 KB | Output is correct |
2 | Incorrect | 2 ms | 2644 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 2644 KB | Output is correct |
2 | Correct | 1 ms | 2688 KB | Output is correct |
3 | Correct | 12 ms | 24916 KB | Output is correct |
4 | Correct | 14 ms | 24404 KB | Output is correct |
5 | Correct | 11 ms | 24336 KB | Output is correct |
6 | Correct | 12 ms | 24532 KB | Output is correct |
7 | Correct | 11 ms | 24432 KB | Output is correct |
8 | Correct | 9 ms | 22948 KB | Output is correct |
9 | Correct | 1 ms | 2644 KB | Output is correct |
10 | Correct | 9 ms | 22920 KB | Output is correct |
11 | Correct | 11 ms | 24464 KB | Output is correct |
12 | Correct | 11 ms | 24352 KB | Output is correct |
13 | Incorrect | 1 ms | 2644 KB | Output isn't correct |
14 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 2644 KB | Output is correct |
2 | Correct | 1 ms | 2688 KB | Output is correct |
3 | Correct | 12 ms | 24916 KB | Output is correct |
4 | Correct | 14 ms | 24404 KB | Output is correct |
5 | Correct | 11 ms | 24336 KB | Output is correct |
6 | Correct | 12 ms | 24532 KB | Output is correct |
7 | Correct | 11 ms | 24432 KB | Output is correct |
8 | Correct | 9 ms | 22948 KB | Output is correct |
9 | Correct | 1 ms | 2644 KB | Output is correct |
10 | Correct | 9 ms | 22920 KB | Output is correct |
11 | Correct | 11 ms | 24464 KB | Output is correct |
12 | Correct | 11 ms | 24352 KB | Output is correct |
13 | Incorrect | 1 ms | 2644 KB | Output isn't correct |
14 | Halted | 0 ms | 0 KB | - |