# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
208537 | eriksuenderhauf | Political Development (BOI17_politicaldevelopment) | C++11 | 430 ms | 31088 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.
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define enl printf("\n")
#define case(t) printf("Case #%d: ", (t))
#define ni(n) scanf("%d", &(n))
#define nl(n) scanf("%lld", &(n))
#define nai(a, n) for (int i = 0; i < (n); i++) ni(a[i])
#define nal(a, n) for (int i = 0; i < (n); i++) nl(a[i])
#define pri(n) printf("%d\n", (n))
#define prl(n) printf("%lld\n", (n))
#define pii pair<int, int>
#define pil pair<int, long long>
#define pll pair<long long, long long>
#define vii vector<pii>
#define vil vector<pil>
#define vll vector<pll>
#define vi vector<int>
#define vl vector<long long>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef cc_hash_table<int,int,hash<int>> ht;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> oset;
const double pi = acos(-1);
const int MOD = 1e9 + 7;
const int INF = 1e9 + 7;
const int MAXN = 1e5 + 5;
const double eps = 1e-9;
set<int> adj[MAXN];
bool vis[MAXN];
int main() {
int n, k;
scanf("%d %d", &n, &k);
priority_queue<pii, vii, greater<pii>> pq;
for (int i = 0; i < n; i++) {
int d;
scanf("%d", &d);
pq.push({d, i});
for (int j = 0; j < d; j++) {
int u;
scanf("%d", &u);
adj[i].insert(u);
}
}
int ans = 1;
while (!pq.empty()) {
pii cur = pq.top(); pq.pop();
int u = cur.se;
if (vis[u])
continue;
vis[u] = 1;
vi tmp = {u};
for (auto it = adj[u].begin(); it != adj[u].end(); it++) {
if (!vis[*it]) {
pq.push({adj[*it].size() - 1, *it});
tmp.pb(*it);
}
}
bool mrk[11][11] = {};
for (int i = 0; i < tmp.size(); i++) {
mrk[i][i] = 1;
for (int j = 0; j < tmp.size(); j++)
if (i != j && adj[tmp[i]].find(tmp[j]) != adj[tmp[i]].end())
mrk[i][j] = 1;
}
int sz = tmp.size();
for (int j = 1; j < (1 << sz); j += 2) {
bool fl = 1;
int cnt = 0;
for (int l = 0; l < sz; l++) {
if ((j >> l) % 2 == 0) continue;
cnt++;
for (int a = 0; a < sz; a++) {
if ((j >> a) % 2 == 0) continue;
if (mrk[l][a] == 0)
fl = 0;
}
if (fl == 0) break;
}
if (fl)
ans = max(ans, cnt);
}
for (int j: tmp) {
if (adj[j].find(u) != adj[j].end())
adj[j].erase(adj[j].find(u));
}
}
printf("%d\n", ans);
return 0;
}
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... |