"Topic link"
Empty time forget to empty the Edge = =re countless hair
In addition to calculate the time to calculate the root node ...
"The YDC."
/* Thank Thunk * * #include <cstdio> #include <cstring> #include <algorithm> using namespace std;
const int MAXN = 10005;
int n, HEAD[MAXN], CNT, Q[MAXN], DP[MAXN], PRE[MAXN];
struct _edge {int V, next;} G[MAXN << 1];
inline int iread () {int f = 1, x = 0; char ch = getchar (); for (; Ch < ' 0 ' | | | ch > ' 9 '; ch = getchar ()) F = ch = = '-'?
-1:1;
for (; Ch >= ' 0 ' && ch <= ' 9 '; ch = getchar ()) x = x * + ch-' 0 ';
return f * x;
} inline void Add (int u, int v) {g[cnt] = (_edge) {V, head[u]};
Head[u] = cnt++; int main () {for (int T = Iread (); T
t--) {n = iread (); for (int i = 1; I <= n; i++) Head[i] =-1, dp[i] = pre[i] = Q[i] = 0;
CNT = 0;
for (int i = 1; i < n; i++) {int u = iread (), V = iread (); Add (U, v);
Add (V, u);
int h = 0, t = 0;
pre[q[t++] = 1] = n + 1;
while (H!= t) {int u = q[h++];
for (int i = head[u]; ~i i = g[i].next) if (!PRE[G[I].V]) pre[q[t++] = g[i].v] = u; } INT ans = n;
for (int i = t-1; ~i; i--) {int u = q[i];
if (dp[u] = = 0) dp[pre[u]]++;
else if (dp[u] = = 1) ans--, dp[pre[u]]++;
else ans-= 2;
printf ("%d\n", ans);
return 0;
}