Submission #1128411

#TimeUsernameProblemLanguageResultExecution timeMemory
1128411stdfloatPolitical Development (BOI17_politicaldevelopment)C++20
77 / 100
3108 ms314336 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); 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...