Submission #785565

#TimeUsernameProblemLanguageResultExecution timeMemory
785565SlavicGPolitical Development (BOI17_politicaldevelopment)C++17
27 / 100
416 ms26216 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; ans = max(ans, __builtin_popcount(mask) + 1); for(int j = 0; j < sz(adj[i]); ++j) { if(mask >> j & 1) continue; bool check = true; for(int k = 0; k < sz(adj[i]); ++k) { if(mask >> k & 1) { if(st[adj[i][j]].find(adj[i][k]) == 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...