Submission #311098

#TimeUsernameProblemLanguageResultExecution timeMemory
311098Vladth11Political Development (BOI17_politicaldevelopment)C++14
0 / 100
54 ms2944 KiB
//Chiar si dupa editorial la sf am avut nevoie de ajutor cum fac cu inceputul si sf. Multumiri sursei lui Dani #include <bits/stdc++.h> #define debug(x) cerr << #x << " " << x << "\n" #define debug_with_space(x) cerr << #x << " " << x << " " using namespace std; typedef long long ll; typedef pair <ll, ll> pii; typedef pair <ll, pii> muchie; const ll NMAX = 100005; const ll INF = (1LL << 60); const ll MOD = 1000000007; const ll BLOCK = 101; vector <int> v[NMAX]; unordered_set <int> st; int main() { // ifstream cin("catsfood.in"); // ofstream cout("catsfood.out"); ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n, k, i, d; cin >> n >> k; for(i = 1; i <= n; i++){ int d; cin >> d; v[i].push_back(i); while(d--){ int x; cin >> x; v[i].push_back(x); } sort(v[i].begin(), v[i].end()); } int maxim = 0; for(i = 1; i <= n; i++){ int nrbits = v[i].size(); for(int mask = 1; mask < (1 << nrbits); mask++){ st.clear(); int cnt = 0; for(int j = nrbits - 1;j >= 0;j--){ if(mask & (1 << j)){ st.insert(j); for(auto x : v[v[i][j]]){ if(st.find(x) != st.end()) cnt++; } } } int bb = __builtin_popcount(mask) + 1; if(cnt == bb * (bb - 1) / 2) maxim = max(maxim, bb); } } cout << maxim; return 0; }

Compilation message (stderr)

politicaldevelopment.cpp: In function 'int main()':
politicaldevelopment.cpp:25:18: warning: unused variable 'd' [-Wunused-variable]
   25 |     int n, k, i, d;
      |                  ^
#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...