传送门
告诉你一些点不能到达1,由于是双向边,也就是1不能到达那些点
那么从1开始dfs,如果当前点能到达不能到达的点,那么当前点就是损坏的。
#include <cstdio> #include <cstring> #include <iostream> #define N 100001 int n, m, p, cnt, tot; int head[N], to[N << 1], next[N << 1]; bool vis[N], flag[N]; inline int read() inline void add(int x, int y) inline void dfs(int u) for(i = head[u]; i ^ 1; i = next[i]) tot++; } int main() for(i = 1; i <= p; i++) dfs(1); printf("%d\n", n tot); return 0; }
上一篇:[luoguP2862] [USACO06JAN]把牛Corral the Cows(二分 + 乱搞)
下一篇:[POJ2443]Set Operation(bitset)
dfs 贪心









