传送门
记录每一个编号在那些组中,可以用vector,这里选择链式前向星。
每一组用set
将被邀请的放到queue中
#include <set> #include <queue> #include <cstdio> #include <cstring> #include <iostream> #define N 1000001 using namespace std; int n, g, cnt, ans; int head[N], to[N], next[N]; queue <int> q; set <int> s[N]; set <int> :: iterator it; bool b[N]; inline int read() inline void add(int x, int y) int main() } q.push(1); while(!q.empty()) } } printf("%d\n", ans); return 0; }
上一篇:[HDU2157]How many ways??(DP + 矩阵优化)
下一篇:【模板】manacher算法
stl









