# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
472584 | Hamed5001 | Political Development (BOI17_politicaldevelopment) | C++14 | 4 ms | 1612 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mxN = 5e4;
vector<int> adj[mxN];
map<int, int> freq;
bool vis[mxN];
int N, K;
bool can(int k) {
vector<pair<int, int>> freq(N, pair<int, int>(0, -1));
for (int i = 0; i < N; i++) {
if (adj[i].size()+1 < k)
continue;
for (int msk = 0; msk < (1<<adj[i].size()); msk++) {
if (__builtin_popcount(msk) != k-1)
continue;
for (int j = 0; j < adj[i].size(); j++) {
if ((1<<j) & msk) {
for (int k = 0; k < adj[j].size(); k++) {
if (freq[adj[j][k]].second != i)
freq[adj[j][k]].second = i, freq[adj[j][k]].first = 0;
freq[adj[j][k]].first++;
}
}
}
}
if (freq[i].first != k-1)
continue;
for (auto it : adj[i])
if (freq[it].first != k-1)
continue;
return 1;
}
return 0;
}
void solve() {
cin >> N >> K;
for (int i = 0; i < N; i++) {
int D;
cin >> D;
while(D--) {
int v;
cin >> v;
adj[i].push_back(v);
}
}
for (int i = K; i >= 1; i--)
if (can(i))
return void(cout << i);
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
solve();
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |