Submission #1128406

#TimeUsernameProblemLanguageResultExecution timeMemory
1128406stdfloatPolitical Development (BOI17_politicaldevelopment)C++20
39 / 100
3106 ms315208 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; int mx; vector<int> v; vector<bool> vis; vector<vector<bool>> edg; vector<vector<int>> E; void dfs(int x) { mx = max(mx, (int)v.size()); for (auto i : E[x]) { if (vis[i]) continue; bool ok = true; for (auto j : v) { if (!edg[i][j] || !edg[j][i]) { ok = false; break; } } if (!ok) continue; vis[i] = true; v.push_back(i); dfs(i); vis[i] = false; v.pop_back(); } } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n, k; cin >> n >> k; E.assign(n, {}); edg.assign(n, vector<bool>(n)); for (int i = 0; i < n; i++) { int d; cin >> d; while (d--) { int y; cin >> y; edg[i][y] = true; E[i].push_back(y); } } for (int i = 0; i < n; i++) { v = {i}; vis.assign(n, false); vis[i] = true; dfs(i); } cout << mx; }
#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...