CF1000E.We Need More Bosses

提高+/省选-

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Your friend is developing a computer game. He has already decided how the game world should look like — it should consist of nn locations connected by mm two-way passages. The passages are designed in such a way that it should be possible to get from any location to any other location.

Of course, some passages should be guarded by the monsters (if you just can go everywhere without any difficulties, then it's not fun, right?). Some crucial passages will be guarded by really fearsome monsters, requiring the hero to prepare for battle and designing his own tactics of defeating them (commonly these kinds of monsters are called bosses). And your friend wants you to help him place these bosses.

The game will start in location ss and end in location tt, but these locations are not chosen yet. After choosing these locations, your friend will place a boss in each passage such that it is impossible to get from ss to tt without using this passage. Your friend wants to place as much bosses as possible (because more challenges means more fun, right?), so he asks you to help him determine the maximum possible number of bosses, considering that any location can be chosen as ss or as tt.

你的朋友正在开发一款电脑游戏。他已确定了游戏世界的设计方案:游戏世界由 nn 个地点和 mm 条双向通道组成,且任意两个地点之间均可相互到达。

当然,某些通道必须由怪物把守(否则玩家可以毫无阻碍地自由通行,游戏岂不是很无趣?)。其中一些关键通道将由极其可怕的怪物(即“Boss”)把守;英雄必须为此提前备战,并设计专门的战术来击败它们。现在,你的朋友希望你协助他安排这些 Boss 的位置。

游戏将从某个起始地点 ss 开始,并在某个终点地点 tt 结束,但 ss 和 tt 尚未选定。一旦选定 ss 和 tt,你的朋友将在所有满足如下条件的通道上各放置一个 Boss:移除该通道后,将无法再从 ss 到达 tt。你的朋友希望尽可能多地放置 Boss(毕竟挑战越多,乐趣越足,对吧?),因此他请你帮忙计算:在允许任选 ss 和 tt 的前提下,Boss 数量的最大可能值是多少?

输入格式

The first line contains two integers nn and mm (2≤n≤3⋅1052 \le n \le 3 \cdot 10^5, n−1≤m≤3⋅105n - 1 \le m \le 3 \cdot 10^5) — the number of locations and passages, respectively.

Then mm lines follow, each containing two integers xx and yy (1≤x,y≤n1 \le x, y \le n, x≠yx \ne y) describing the endpoints of one of the passages.

It is guaranteed that there is no pair of locations directly connected by two or more passages, and that any location is reachable from any other location.

第一行包含两个整数 nn 和 mm(2≤n≤3⋅1052 \le n \le 3 \cdot 10^5,n−1≤m≤3⋅105n - 1 \le m \le 3 \cdot 10^5),分别表示地点的数量和通道的数量。

接下来是 mm 行,每行包含两个整数 xx 和 yy(1≤x,y≤n1 \le x, y \le n,x≠yx \ne y),描述某一条通道的两个端点。

保证不存在任意两个地点之间被两条或更多通道直接连接,且任意地点均可从其他任意地点到达。

输出格式

Print one integer — the maximum number of bosses your friend can place, considering all possible choices for ss and tt.

输出一个整数——在所有可能的 ss 和 tt 的选择下,你的朋友最多可以放置的 Boss 数量。

输入输出样例

  • 输入#1

    5 5
    1 2
    2 3
    3 1
    4 1
    5 2

    输出#1

    2
  • 输入#2

    4 3
    1 2
    4 3
    3 2

    输出#2

    3

输入解题思路,AI测评打分。不知道怎么写?

首页