PivotOJ

Triples of Cows

시간 제한: 2000ms메모리 제한: 1024MB출처: USACO 2023 Open PlatinumBOJ 28027

문제

There are initially N1N-1 pairs of friends among FJ's NN (2N21052\le N\le 2\cdot 10^5) cows labeled 1N1\dots N, forming a tree. The cows are leaving the farm for vacation one by one. On day ii, the iith cow leaves the farm, and then all pairs of the iith cow's friends still present on the farm become friends.

For each ii from 11 to NN, just before the iith cow leaves, how many ordered triples of distinct cows (a,b,c)(a,b,c) are there such that none of a,b,ca,b,c are on vacation, aa is friends with bb, and bb is friends with cc?

입력

The first line contains NN.

The next N1N-1 lines contain two integers uiu_i and viv_i denoting that cows uiu_i and viv_i are initially friends (1ui,viN1\le u_i,v_i\le N).

출력

The answers for ii from 11 to NN on separate lines.

예제

예제 1

입력
3
1 2
2 3
출력
2
0
0

예제 2

입력
4
1 2
1 3
1 4
출력
6
6
0
0

예제 3

입력
5
3 5
5 1
1 4
1 2
출력
8
10
2
0
0
코드를 제출하려면 로그인하세요.