Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|---|
52451 | AK2022071311 | 子网 | C++ | 运行出错 | 20 | 14 MS | 1356 KB | 1033 | 2022-07-19 12:13:47 |
#include<iostream> #include<cstdio> #include<algorithm> #include<vector> using namespace std; inline int read(){ int x = 0, f = 1; char ch = getchar(); while(ch < '0' || ch > '9'){ if(ch == '-') f = -1; ch = getchar(); } while(ch >= '0' && ch <= '9'){ x = x * 10 + ch - 48; ch = getchar(); } return x * f; } vector <int> li[4405]; int n, m; bool b[8005]; int dfs(int pos, int cnt){ if(pos == n) return cnt; int maxn = 0; for(int i = 0; i < li[pos].size(); i++){ int u = li[pos][i]; if(b[u]) continue; b[u] = 1; for(int j = i + 1; j < li[pos].size(); j++){ if(b[li[pos][j]]) continue; int v = li[pos][j]; b[v] = 1; maxn = max(maxn, dfs(pos + 1, cnt + 1)); b[v] = 0; } b[u] = 0; } return max(maxn, dfs(pos + 1, cnt)); } int main(){ n = read(), m = read(); for(int i = 0, l; i < m; i++){ l = read(); for(int j = 1, u; j <= l; j++){ u = read(); li[i].push_back(u); } } printf("%d", dfs(0, 0)); return 0; }