CF191D.Metro Scheme

省选/NOI-

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

Berland is very concerned with privacy, so almost all plans and blueprints are secret. However, a spy of the neighboring state managed to steal the Bertown subway scheme.

The Bertown Subway has n stations, numbered from 1 to n, and m bidirectional tunnels connecting them. All Bertown Subway consists of lines. To be more precise, there are two types of lines: circular and radial.

A radial line is a sequence of stations _v_1, ..., v__k (k > 1), where stations v__i and v__i + 1 (i < k) are connected by a tunnel and no station occurs in the line more than once (v__i ≠ v__j for i ≠ j).

A loop line is a series of stations, _v_1, ..., v__k (k > 2), where stations v__i и v__i + 1 are connected by a tunnel. In addition, stations _v_1 and v__k are also connected by a tunnel. No station is occurs in the loop line more than once.

Note that a single station can be passed by any number of lines.

According to Berland standards, there can't be more than one tunnel between two stations and each tunnel belongs to exactly one line. Naturally, each line has at least one tunnel. Between any two stations there is the way along the subway tunnels. In addition, in terms of graph theory, a subway is a vertex cactus: if we consider the subway as a graph in which the stations are the vertexes and the edges are tunnels, then each vertex lies on no more than one simple cycle.

Unfortunately, scheme, stolen by the spy, had only the stations and the tunnels. It was impossible to determine to which line every tunnel corresponds. But to sabotage successfully, the spy needs to know what minimum and maximum number of lines may be in the Bertown subway.

Help him!

伯兰德非常重视隐私,因此几乎所有计划和蓝图都是保密的。然而,邻国的一名间谍成功窃取了贝尔镇地铁系统的方案。

贝尔镇地铁系统共有 nn 个车站,编号从 11 到 nn,以及 mm 条双向隧道连接这些车站。整个贝尔镇地铁系统由若干条线路构成。更准确地说,线路分为两类:环形线路(loop line)与放射状线路(radial line)。

一条放射状线路是一列车站 v1,…,vkv_1,\dots,v_k(其中 k>1k > 1),满足:对任意 i<ki < k,车站 viv_i 与 vi+1v_{i+1} 之间有一条隧道相连,且该序列中任意两个不同位置的车站互不相同(即当 i≠ji \ne j 时,vi≠vjv_i \ne v_j)。

一条环形线路是一列车站 v1,…,vkv_1,\dots,v_k(其中 k>2k > 2),满足:对任意 i<ki < k,车站 viv_i 与 vi+1v_{i+1} 之间有一条隧道相连;此外,车站 v1v_1 与 vkv_k 之间也有一条隧道相连;且该序列中任意两个不同位置的车站互不相同。

注意:一个车站可以属于任意数量的线路。

根据伯兰德标准,任意两个车站之间至多只有一条隧道,且每条隧道恰好属于一条线路。显然,每条线路至少包含一条隧道。任意两个车站之间均存在一条仅经由地铁隧道的路径。此外,从图论角度看,该地铁系统是一个点仙人掌图(vertex cactus):若将地铁系统视为一张图,其中车站为顶点、隧道为边,则图中每个顶点至多位于一个简单环上。

不幸的是,间谍窃取到的方案中仅包含车站和隧道信息,无法确定每条隧道所属的具体线路。但为了成功实施破坏行动,间谍需要知道贝尔镇地铁系统中线路数的最小可能值与最大可能值。

请帮助他!

输入格式

The first line contains two integers n and m (1 ≤ n ≤ 105, 0 ≤ m ≤ 3·105) — the number of stations and the number of tunnels, correspondingly.

Each of the next m lines contain two integers — the numbers of stations connected by the corresponding tunnel. The stations are numbered with integers from 1 to n.

It is guaranteed that the graph that corresponds to the subway has no multiple edges or loops, it is connected and it is a vertex cactus.

第一行包含两个整数 nn 和 mm(1≤n≤1051 \leq n \leq 10^5,0≤m≤3⋅1050 \leq m \leq 3 \cdot 10^5),分别表示车站的数量和隧道的数量。

接下来的 mm 行中,每行包含两个整数,表示由对应隧道连接的两个车站的编号。车站编号为从 11 到 nn 的整数。

保证该地铁所对应的图不含重边或自环,是连通的,且是一个点仙人掌图(vertex cactus)。

输出格式

Print two numbers — the minimum and maximum number of lines correspondingly.

输出两个数字——分别表示最少和最多的行数。

输入输出样例

  • 输入#1

    3 3
    1 2
    2 3
    3 1

    输出#1

    1 3
  • 输入#2

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

    输出#2

    2 8
  • 输入#3

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

    输出#3

    3 6

说明/提示

The subway scheme with minimum possible number of lines for the second sample is:

第二个样例中线路数量最少的地铁方案为:

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

首页