QOJ.ac

QOJ

Limite de temps : 1 s Limite de mémoire : 256 MB Points totaux : 100

#1405. 电压

Statistiques

你知道 Just Odd Inventions 公司吗?这家公司的业务就是进行“奇妙的发明 (just odd inventions)”。在此简称为 JOI 公司。

JOI 公司的一间实验室里有一个复杂的电路。该电路包含 $N$ 个节点和 $M$ 条细长的电阻。节点编号为 $1$ 到 $N$。每个节点都可以被设置为“高电压”或“低电压”状态。每条电阻连接两个节点,当且仅当这两个节点中一个处于“高电压”状态,另一个处于“低电压”状态时,电流才会流过该电阻。如果连接的两个节点同为“高电压”或同为“低电压”,则电阻中没有电流流过。

某天,为了维护电路,JOI 公司决定选择一条电阻,通过设置各节点的电压,使得只有这条电阻中没有电流流过,而其余 $M-1$ 条电阻中都有电流流过。为了满足这一条件,有多少条电阻可以被选为“没有电流流过的电阻”?

顺便一提,JOI 公司利用这个奇妙的电路在进行什么样的发明,是公司内部的最高机密,除了社长以外无人知晓。

题目描述

给定电路的信息,编写一个程序,计算在维护时可以被选为“没有电流流过的电阻”的电阻数量。

输入格式

从标准输入读取以下数据:

  • 第 $1$ 行包含两个整数 $N, M$,用空格分隔,表示节点数为 $N$,电阻数为 $M$。
  • 接下来的 $M$ 行中的第 $i$ 行 ($1 \le i \le M$) 包含两个整数 $A_i, B_i$ ($1 \le A_i \le N, 1 \le B_i \le N, A_i \neq B_i$),用空格分隔,表示第 $i$ 条电阻连接节点 $A_i$ 和节点 $B_i$。

输出格式

将维护时可以选为“没有电流流过的电阻”的数量输出到标准输出,占一行。

数据范围

所有输入数据满足以下条件:

  • $2 \le N \le 100\,000$
  • $1 \le M \le 200\,000$

子任务

子任务 1 [10 分]

满足以下条件: $N \le 1\,000$ $M \le 2\,000$

子任务 2 [10 分]

  • 任意两个节点之间都可以通过若干条电阻相互到达。
  • 满足 $M = N$。

子任务 3 [35 分]

  • 任意两个节点之间都可以通过若干条电阻相互到达。
  • 满足 $M \le N + 100$。

子任务 4 [45 分]

没有额外限制。

样例

样例输入 1

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

样例输出 1

1

说明 1

在这个例子中,可以使第 $3$ 条电阻中没有电流流过。例如,将节点 $1$ 和节点 $4$ 设置为“高电压”,将节点 $2$ 和节点 $3$ 设置为“低电压”即可。由于第 $3$ 条电阻连接的是节点 $1$ 和节点 $4$,因此第 $3$ 条电阻中没有电流流过。 除了第 $3$ 条电阻外,无法选择其他电阻作为维护时没有电流流过的电阻。

样例输入 2

4 4
1 2
2 3
3 2
4 3

样例输出 2

2

说明 2

在这个例子中,可以选择第 $1$ 条电阻或第 $4$ 条电阻作为维护时没有电流流过的电阻。

样例输入 3

13 16
1 6
2 6
3 1
3 2
4 7
4 7
5 9
6 5
8 2
8 13
9 11
10 3
11 10
11 12
12 8
13 6

样例输出 3

3

Editorials

IDTypeStatusTitlePosted ByLast UpdatedActions
EditorialOpen Official EditorialQingyu- Download

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.