Submission #1128986

#TimeUsernameProblemLanguageResultExecution timeMemory
1128986MuhammetPolitical Development (BOI17_politicaldevelopment)C++20
16 / 100
3093 ms589824 KiB
#include "bits/stdc++.h" using namespace std; #define SZ(s) (int)s.size() int n, k, ans; bool vis[5005], a[5005][5005]; vector <int> v1; vector <vector <int>> v; void dfs(int x){ ans = max(ans, SZ(v1)); for(auto i : v[x]){ if(vis[i]) continue; bool tr = 0; for(auto j : v1){ if(!a[i][j] or !a[j][i]){ tr = 1; break; } } if(!tr){ v1.push_back(i); vis[i] = true; dfs(i); vis[i] = false; v1.pop_back(); } } } int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); cin >> n >> k; v.resize(n+1); bool tr = 0; for(int i = 0; i < n; i++){ int d; cin >> d; if(d != 0) tr = 1; while(d--){ int x; cin >> x; a[i][x] = true; v[i].push_back(x); } } for(int i = 0; i < n; i++){ v1.push_back(i); vis[i] = true; dfs(i); vis[i] = false; v1.pop_back(); } cout << ans; }
#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...