306584: CF1218A. BubbleReactor

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

BubbleReactor

题意翻译

### 题目描述 你负责``BubbleReactor``。它由$n$根连接在$n$根电线上的``BubbleCore``组成。每个电线连接两个不同的``BubbleCore``。没有一条以上电线连接的``BubbleCore``。 你的任务是通过启动每一个``BubbleCore``来启动``BubbleReactor``。为了启动``BubbleCore``,它需要从已启动的直接连接的``BubbleCore``接收电源。但是,您可以手动启动一个``BubbleCore``而不需要电源。保证所有``BubbleCore``都能启动。 在每个``BubbleCore``启动之前,它的电位是根据它所能启动的``BubbleCore``数量计算的(直接连接到它的未启动的``BubbleCore``数量、间接连接它的未启动的``BubbleCore``数量和它自己) 启动``BubbleReactor``,使所有``BubbleCore``电位的总和达到最大。 ### 输入格式 第一行包含一个整数$n$($3\leq n\leq 15000$),即``BubbleCore``数。 下面的$n$行包含两个整数$u$,$v$($0\leq u\neq v<n$),表示``Bubblecore`` $u$和$v$之间存在电线。 ### 输出格式 一个整数,代表所有``BubbleCore``电位的总和的最大值。 ### 说明/提示 如果我们先启动``BubbleCore`` $8$,然后打开``BubbleCore`` $7$,$2$,$1$,$3$,$0$,$9$,$4$,$5$,$6$,我们得到$10+9+8+7+6+5+1+3+1+1=51$的电位值。

题目描述

You are in charge of the BubbleReactor. It consists of $ N $ BubbleCores connected with $ N $ lines of electrical wiring. Each electrical wiring connects two distinct BubbleCores. There are no BubbleCores connected with more than one line of electrical wiring. Your task is to start the BubbleReactor by starting each BubbleCore. In order for a BubbleCore to be started it needs to be receiving power from a directly connected BubbleCore which is already started. However, you can kick-start one BubbleCore manually without needing power. It is guaranteed that all BubbleCores can be started. Before the BubbleCore boot up procedure its potential is calculated as the number of BubbleCores it can power on (the number of inactive BubbleCores which are connected to it directly or with any number of inactive BubbleCores in between, itself included) Start the BubbleReactor so that the sum of all BubbleCores' potentials is maximum.

输入输出格式

输入格式


First line contains one integer $ N (3 \leq N \leq 15.000) $ , the number of BubbleCores. The following N lines contain two integers $ U, V (0 \leq U \neq V < N) $ denoting that there exists electrical wiring between BubbleCores $ U $ and $ V $ .

输出格式


Single integer, the maximum sum of all BubbleCores' potentials.

输入输出样例

输入样例 #1

10
0 1
0 3
0 4
0 9
1 2
2 3
2 7
4 5
4 6
7 8

输出样例 #1

51

说明

If we start by kickstarting BubbleCup 8 and then turning on cores 7, 2, 1, 3, 0, 9, 4, 5, 6 in that order we get potentials 10 + 9 + 8 + 7 + 6 + 5 + 1 + 3 + 1 + 1 = 51

Input

题意翻译

### 题目描述 你负责``BubbleReactor``。它由$n$根连接在$n$根电线上的``BubbleCore``组成。每个电线连接两个不同的``BubbleCore``。没有一条以上电线连接的``BubbleCore``。 你的任务是通过启动每一个``BubbleCore``来启动``BubbleReactor``。为了启动``BubbleCore``,它需要从已启动的直接连接的``BubbleCore``接收电源。但是,您可以手动启动一个``BubbleCore``而不需要电源。保证所有``BubbleCore``都能启动。 在每个``BubbleCore``启动之前,它的电位是根据它所能启动的``BubbleCore``数量计算的(直接连接到它的未启动的``BubbleCore``数量、间接连接它的未启动的``BubbleCore``数量和它自己) 启动``BubbleReactor``,使所有``BubbleCore``电位的总和达到最大。 ### 输入格式 第一行包含一个整数$n$($3\leq n\leq 15000$),即``BubbleCore``数。 下面的$n$行包含两个整数$u$,$v$($0\leq u\neq v<n$),表示``Bubblecore`` $u$和$v$之间存在电线。 ### 输出格式 一个整数,代表所有``BubbleCore``电位的总和的最大值。 ### 说明/提示 如果我们先启动``BubbleCore`` $8$,然后打开``BubbleCore`` $7$,$2$,$1$,$3$,$0$,$9$,$4$,$5$,$6$,我们得到$10+9+8+7+6+5+1+3+1+1=51$的电位值。

加入题单

算法标签: