Submission #785576

#TimeUsernameProblemLanguageResultExecution timeMemory
785576SlavicGPolitical Development (BOI17_politicaldevelopment)C++17
27 / 100
443 ms26128 KiB
#include "bits/stdc++.h" using namespace std; #define ll long long #define all(v) v.begin(), v.end() #define rall(v) v.rbegin(),v.rend() #define pb push_back #define sz(a) (int)a.size() void solve() { int n, k; cin >> n >> k; unordered_set<int> st[n + 1]; vector<vector<int>> adj(n); for(int i = 0; i < n; ++i) { int x; cin >> x; if(x >= 1) { adj[i].resize(x); for(int j = 0; j < x; ++j) { cin >> adj[i][j]; st[i].insert(adj[i][j]); st[adj[i][j]].insert(i); } } } int ans = 1; for(int i = 0; i < n; ++i) { if(sz(adj[i]) >= k) continue; vector<int> dp(1 << (sz(adj[i])), 0); dp[0] = 1; for(int mask = 0; mask < (1 << (sz(adj[i]))); ++mask) { if(!dp[mask]) continue; int cnt = 1; for(int f = 0; f < sz(adj[i]); ++f) { if(mask >> f & 1) ++cnt; } ans = max(ans, cnt); for(int j = 0; j < sz(adj[i]); ++j) { if(mask >> j & 1) continue; bool check = true; for(int f = 0; f < sz(adj[i]); ++f) { if(mask >> f & 1) { if(st[adj[i][j]].find(adj[i][f]) == st[adj[i][j]].end()) check = false; } } if(check) dp[mask | (1 << j)] = 1; } } } cout << ans << "\n"; } int32_t main() { ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); int t = 1; //cin >> t; while(t--) { solve(); } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...