CF1218A.BubbleReactor
省选/NOI-
通过率:0%
时间限制:1.50s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
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.
你负责操作“气泡反应堆”(BubbleReactor)。它由 N 个“气泡核心”(BubbleCore)组成,彼此之间通过 N 条电线连接。每条电线连接两个不同的气泡核心,且任意两个气泡核心之间至多只有一条电线相连。
你的任务是启动整个气泡反应堆,即启动全部气泡核心。一个气泡核心要被启动,必须从某个已启动的、且与之直接相连的气泡核心处获得电力。但你可以手动启动一个气泡核心(即无需依赖电力),作为启动过程的起点。题目保证所有气泡核心均可被启动。
在气泡核心启动前,需计算其潜力值(potential):即该气泡核心所能启动的气泡核心总数(包括自身),定义为——从该气泡核心出发,仅经过尚未启动的气泡核心(即处于非活跃状态),所能到达的所有气泡核心的数量(自身也计入其中)。
请设计一种启动顺序,使得所有气泡核心的潜力值之和达到最大。
输入格式
First line contains one integer N(3≤N≤15.000), the number of BubbleCores.
The following N lines contain two integers U,V(0≤U=V<N) denoting that there exists electrical wiring between BubbleCores U and V.
第一行包含一个整数 N(3≤N≤15000),表示 BubbleCore 的数量。
接下来的 N 行每行包含两个整数 U 和 V(0≤U=V<N),表示 BubbleCore U 与 BubbleCore V 之间存在电气连线。
输出格式
Single integer, the maximum sum of all BubbleCores' potentials.
单个整数,表示所有 BubbleCore 势能的最大总和。
输入输出样例
输入#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
如果我们首先启动 BubbleCup 8,然后按顺序开启核心 7、2、1、3、0、9、4、5、6,则得到的势能值为 10+9+8+7+6+5+1+3+1+1=51。
输入解题思路,AI测评打分。不知道怎么写?