# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
764672 | 2023-06-23T20:52:36 Z | adrilen | Political Development (BOI17_politicaldevelopment) | C++17 | 14 ms | 5204 KB |
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using arr = array<int, 2>; constexpr int maxn = 5e4, maxk = 11; bool visited[maxn] = { 0 }; set<int> adj[maxn]; int k; int output = 1; void dfs(int pos) { assert(!visited[pos]); assert(adj[pos].size() <= k); // cout << pos << endl; visited[pos] = true; vector <bitset<maxk>> v(adj[pos].size()); int ii = 0; // Counts which place it is in the order of adj[pos] int iii; for (int i : adj[pos]) { auto it = adj[pos].begin(); auto ft = adj[i].begin(); iii = 0; v[ii][ii] = true; while (it != adj[pos].end() && ft != adj[i].end()) { if (*it < *ft) { it++; iii++; continue; } if (*ft < *it) { ft++; continue; } v[ii][iii] = true; it++, ft++; iii++; } ii++; } bitset<maxk> all; for (int i = 1; i < (1 << (adj[pos].size())); i++){ all.set(); for (size_t y = 0; y < adj[pos].size(); y++) { if (i & (1 << y)) all &= v[y]; } // cout << i << " " << all << "\n"; if (__builtin_popcount(i) == all.count()) output = max(output, __builtin_popcount(i) + 1); } for (int i : adj[pos]) adj[i].erase(pos); for (int i : adj[pos]) if ((int)adj[i].size() <= k) dfs(i); } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n; cin >> n >> k; for (int i = 0; i < n; i++) { int a, b; cin >> a; for (int y = 0; y < a; y++) { cin >> b; adj[i].insert(b); } } for (int i = 0; i < n; i++) if (!visited[i] && (int)adj[i].size() <= k) dfs(i); cout << output << "\n"; // cerr << clock() / static_cast<double>(CLOCKS_PER_SEC) << "\n"; } /* Det er en ganske spesiell graf og derfor kan */
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 2644 KB | Output is correct |
2 | Correct | 2 ms | 2644 KB | Output is correct |
3 | Correct | 5 ms | 3152 KB | Output is correct |
4 | Correct | 11 ms | 3144 KB | Output is correct |
5 | Correct | 14 ms | 3080 KB | Output is correct |
6 | Correct | 5 ms | 3028 KB | Output is correct |
7 | Correct | 4 ms | 3028 KB | Output is correct |
8 | Correct | 1 ms | 2644 KB | Output is correct |
9 | Correct | 1 ms | 2644 KB | Output is correct |
10 | Correct | 2 ms | 2644 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 2644 KB | Output is correct |
2 | Correct | 2 ms | 2644 KB | Output is correct |
3 | Correct | 5 ms | 3152 KB | Output is correct |
4 | Correct | 11 ms | 3144 KB | Output is correct |
5 | Correct | 14 ms | 3080 KB | Output is correct |
6 | Correct | 5 ms | 3028 KB | Output is correct |
7 | Correct | 4 ms | 3028 KB | Output is correct |
8 | Correct | 1 ms | 2644 KB | Output is correct |
9 | Correct | 1 ms | 2644 KB | Output is correct |
10 | Correct | 2 ms | 2644 KB | Output is correct |
11 | Correct | 7 ms | 3144 KB | Output is correct |
12 | Correct | 9 ms | 3140 KB | Output is correct |
13 | Runtime error | 4 ms | 5204 KB | Execution killed with signal 6 |
14 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 2644 KB | Output is correct |
2 | Runtime error | 3 ms | 5204 KB | Execution killed with signal 6 |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 2644 KB | Output is correct |
2 | Correct | 2 ms | 2644 KB | Output is correct |
3 | Correct | 5 ms | 3152 KB | Output is correct |
4 | Correct | 11 ms | 3144 KB | Output is correct |
5 | Correct | 14 ms | 3080 KB | Output is correct |
6 | Correct | 5 ms | 3028 KB | Output is correct |
7 | Correct | 4 ms | 3028 KB | Output is correct |
8 | Correct | 1 ms | 2644 KB | Output is correct |
9 | Correct | 1 ms | 2644 KB | Output is correct |
10 | Correct | 2 ms | 2644 KB | Output is correct |
11 | Correct | 7 ms | 3144 KB | Output is correct |
12 | Correct | 9 ms | 3140 KB | Output is correct |
13 | Runtime error | 4 ms | 5204 KB | Execution killed with signal 6 |
14 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 2644 KB | Output is correct |
2 | Correct | 2 ms | 2644 KB | Output is correct |
3 | Correct | 5 ms | 3152 KB | Output is correct |
4 | Correct | 11 ms | 3144 KB | Output is correct |
5 | Correct | 14 ms | 3080 KB | Output is correct |
6 | Correct | 5 ms | 3028 KB | Output is correct |
7 | Correct | 4 ms | 3028 KB | Output is correct |
8 | Correct | 1 ms | 2644 KB | Output is correct |
9 | Correct | 1 ms | 2644 KB | Output is correct |
10 | Correct | 2 ms | 2644 KB | Output is correct |
11 | Correct | 7 ms | 3144 KB | Output is correct |
12 | Correct | 9 ms | 3140 KB | Output is correct |
13 | Runtime error | 4 ms | 5204 KB | Execution killed with signal 6 |
14 | Halted | 0 ms | 0 KB | - |