QOJ.ac

QOJ

حد الوقت: 3 s حد الذاكرة: 64 MB مجموع النقاط: 100

#5284. 关键网络线路

الإحصائيات

考虑一个通信网络,它由一组节点和连接节点对的双向直接通信线路组成。已知该网络是连通的,即任意两个节点之间都存在通信路径。某些节点向所有节点(包括自身)提供 A 类服务,而某些节点向所有节点(包括自身)提供 B 类服务。同一个节点可能同时提供两种服务。每个节点都必须能够访问这两种服务。

如果某条直接线路中断,可能会导致某些节点无法获得某种服务;具有此性质的直接线路被称为关键网络线路。

任务

你需要编写一个程序,确定关键网络线路的数量(子任务 A)以及它们所连接的节点对(子任务 B)。

输入格式

输入文件的第一行包含四个整数 $N, M, K$ 和 $L$。$N$ ($1 \le N \le 100\,000$) 是网络中的节点数,$M$ ($1 \le M \le 1\,000\,000$) 是直接通信线路的数量,$K$ ($1 \le K \le N$) 是提供 A 类服务的节点数量,$L$ ($1 \le L \le N$) 是提供 B 类服务的节点数量。节点编号为 $1$ 到 $N$。第二行包含 $K$ 个整数,即提供 A 类服务的节点编号。第三行包含 $L$ 个整数,即提供 B 类服务的节点编号。接下来的 $M$ 行,每行包含一对整数 $p, q$ ($1 \le p, q \le N, p \neq q$),定义了一条直接通信线路。任意两个节点之间最多只有一条直接通信线路。

输出格式

输出文件的第一行包含一个整数 $S$,即网络中关键线路的数量(子任务 A)。接下来的 $S$ 行,每行包含一对整数 $p, q$ ($1 \le p, q \le N$),定义了一条关键网络线路(子任务 B)。你可以以任意顺序输出关键网络线路,对于每条线路,你也可以以任意顺序输出其端点。

样例

输入 1

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

输出 1

3
3 2
5 6
7 9

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.