Submission #1128474

#TimeUsernameProblemLanguageResultExecution timeMemory
1128474AgageldiPolitical Development (BOI17_politicaldevelopment)C++20
0 / 100
3093 ms9288 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define N 400005 #define ff first #define ss second #define pb push_back #define sz(s) (int)s.size() #define rep(c, a, b) for(c = a; c <= b; c++) ll n, t, T, a[N][11], m[N], k, b[N], answer; set <int> s; void solve(int x,int cnt) { if(cnt > k) return; if(x == n+1) { ll p = sz(s); answer = max(answer,p); return; } bool tr = 1; for(auto i : s) { tr = 0; for(int j = 1; j <= m[i]; j++) { if(a[i][j] == x){ tr = 1; break; } } if(!tr) break; } if(tr) { b[x] = 1; s.insert(x); solve(x + 1,cnt + 1); s.erase(*(--s.end())); } b[x] = 0; solve(x + 1,cnt); } int main () { ios::sync_with_stdio(0);cin.tie(0); cin >> n >> k; for(int i = 1; i <= n; i++) { cin >> m[i]; for(int j = 1; j <= m[i]; j++) { cin >>a[i][j]; a[i][j]++; } } solve(1,0); cout << answer << '\n'; }
#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...