#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
const int N = 1e6 + 5, M = 250010;
vector<int> ac[M];
int n, m, t, res, tot, key, x;
bool st[N];
int main()
{
ios::sync_with_stdio(false), cin.tie(0);
cin >> n >> m;
for (int i = 1; i <= m; i++)
{
cin >> t;
for (int j = 0; j < t; j++)
cin >> x, ac[i].push_back(x);
sort(ac[i].begin(), ac[i].end());
}
st[1] = true, res = 1;
for (int i = 1; i <= m; i++)
{
tot = 0;
for (int j = 0; j < ac[i].size(); j++)
if (!st[ac[i][j]])
tot++, key = ac[i][j];
if (tot == 1)
st[key] = true, res++;
}
cout << res << endl;
}
感觉很自然就写的这个啊,交上去20分。这个代码又不会TMLE,那是代码逻辑有问题?