Logo
(追記) (追記ここまで)

33095번 - Independent Set (Max) 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 2048 MB32151550.000%

문제

You are given a tree of $N$ nodes (numbered from 1ドル$ to $N$). The edges are numbered from 1ドル$ to $N - 1$; edge $i$ connects node $U_i$ and $V_i$.

A non-empty set of nodes is independent if none of the nodes in the set are adjacent to each other. The following illustration provides an example of sets which are independent, and sets which are not. The nodes colored in red are the members of the set.

The score of an independent set can be calculated as the product of:

  • the number of nodes in the set, and
  • the minimum number of edges such that all nodes in the set are still connected.

The following illustration provides an example for calculating the score of an independent set. There are 2ドル$ nodes in the set. The minimum number of edges to connect all nodes in the set is 3ドル,ドル as shown by the edges colored in red. The score of this set is 2ドル \cdot 3 = 6$.

Note that the score of an independent set consisting of only 1ドル$ node is 0ドル$.

Determine the maximum score over all non-empty independent sets within the tree.

입력

The first line consists of an integer $N$ (2ドル ≤ N ≤ 100,円 000$).

Each of the next $N - 1$ lines consists two integers $U_i$ $V_i$ (1ドル ≤ U_i , V_i ≤ N$). The input edges form a tree.

출력

Output a single integer representing the maximum score over all non-empty independent sets within the tree.

제한

예제 입력 1

5
1 2
1 3
3 4
3 5

예제 출력 1

12

The following illustration shows all independent sets with scores larger than 0ドル$. The nodes colored in red are members of the independent set. The edges colored in red connect all nodes in the set.

The set with the largest score is illustrated by the bottom-right-most tree. The set consists of 3ドル$ nodes and it requires all edges to connect those nodes. The score of this set is 3ドル \cdot 4 = 12,ドル which can be shown is the maximum score.

예제 입력 2

8
1 2
2 3
3 4
4 5
5 6
6 7
7 8

예제 출력 2

28

힌트

출처

ICPC > Regionals > Asia Pacific > Indonesia > Indonesia National Contest > INC 2023 C번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /