CF732F.Tourist Reform

提高+/省选-

通过率:0%

时间限制:4.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

Berland is a tourist country! At least, it can become such — the government of Berland is confident about this.

There are n cities in Berland, some pairs of which are connected by two-ways roads. Each road connects two different cities. In Berland there are no roads which connect the same pair of cities. It is possible to get from any city to any other city using given two-ways roads.

According to the reform each road will become one-way. It will be oriented to one of two directions.

To maximize the tourist attraction of Berland, after the reform for each city i the value r__i will be calculated. It will equal to the number of cities x for which there is an oriented path from the city i to the city x. In other words, r__i will equal the number of cities which can be reached from the city i by roads.

The government is sure that tourist's attention will be focused on the minimum value of r__i.

Help the government of Berland make the reform to maximize the minimum of r__i.

Berland 是一个旅游国家!至少,它有潜力成为这样的国家——Berland 政府对此充满信心。

Berland 共有 nn 座城市,其中某些城市对之间由双向道路连接。每条道路连接两个不同的城市。Berland 中不存在连接同一对城市的多条道路(即无重边)。任意两座城市之间均可通过给定的双向道路相互到达(即图是连通的)。

根据改革方案,每条道路都将变为单向道路,即被赋予两个可能方向中的一个。

为了最大化 Berland 的旅游吸引力,在改革完成后,将为每座城市 ii 计算一个值 rir_i,其定义为:从城市 ii 出发,存在一条有向路径可达的城市 xx 的数量。换言之,rir_i 表示从城市 ii 出发、沿道路方向所能到达的城市总数。

政府确信,游客的关注点将集中于所有 rir_i 中的最小值。

请帮助 Berland 政府实施此次改革,使得 min⁡1≤i≤nri\min\limits_{1 \le i \le n} r_i 尽可能大。

输入格式

The first line contains two integers n, m (2 ≤ n ≤ 400 000, 1 ≤ m ≤ 400 000) — the number of cities and the number of roads.

The next m lines describe roads in Berland: the j-th of them contains two integers u__j and v__j (1 ≤ u__j, v__j ≤ n, u__j ≠ v__j), where u__j and v__j are the numbers of cities which are connected by the j-th road.

The cities are numbered from 1 to n. It is guaranteed that it is possible to get from any city to any other by following two-ways roads. In Berland there are no roads which connect the same pair of cities.

第一行包含两个整数 nn 和 mm(2≤n≤400 0002 \leq n \leq 400\,000,1≤m≤400 0001 \leq m \leq 400\,000)——分别表示城市的数量和道路的数量。

接下来的 mm 行描述了 Berland 国内的道路:其中第 jj 行包含两个整数 uju_j 和 vjv_j(1≤uj,vj≤n1 \leq u_j, v_j \leq n,uj≠vju_j \neq v_j),表示第 jj 条道路连接的城市编号分别为 uju_j 和 vjv_j。

城市编号从 11 到 nn。保证任意两座城市之间均可通过双向道路相互到达。Berland 国内不存在连接同一对城市的多条道路。

输出格式

In the first line print single integer — the maximum possible value _min_1 ≤ i ≤ n{r__i} after the orientation of roads.

The next m lines must contain the description of roads after the orientation: the j-th of them must contain two integers u__j, v__j, it means that the j-th road will be directed from the city u__j to the city v__j. Print roads in the same order as they are given in the input data.

第一行输出一个整数——道路定向后 min⁡1 ≤ i ≤ nri\min_{1 \leq i \leq n} r_i 的最大可能值。

接下来 mm 行需包含道路定向后的描述:其中第 jj 行应包含两个整数 uj, vju_j,\,v_j,表示第 jj 条道路将从城市 uju_j 指向城市 vjv_j。请按输入数据中给出的相同顺序输出各条道路。

输入输出样例

  • 输入#1

    7 9
    4 3
    2 6
    7 1
    4 1
    7 3
    3 5
    7 4
    6 5
    2 5

    输出#1

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

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

首页