Codeforces-Bertown Subway(思维)

本文讨论了Bertown城市地铁建设的情况,其中每个车站都有一条通往特定目的地的列车,并且每站都有一个回程站。为了提高地铁的便利性,市长考虑在总统参观前最多改变两条路线。便利性定义为乘客可以从任一站出发并到达另一站的有序对数量。题目要求计算通过最多两次调整所能达到的最大便利性。给出的解决方案包括计算每个连通块的大小,将最大的两个连通块合并,并计算总的可能性。
摘要由CSDN通过智能技术生成
C. Bertown Subway
time limit per test:1 second
memory limit per test:256 megabytes
input:standard input
output:standard output

The construction of subway in Bertown is almost finished! The President of Berland will visit this city soon to look at the new subway himself.

There are n stations in the subway. It was built according to the Bertown Transport Law:

  1. For each station i there exists exactly one train that goes from this station. Its destination station is pi, possibly pi = i;
  2. For each station i there exists exactly one station
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值