CF555E.Case of Computer Network
省选/NOI-
通过率:0%
时间限制:3.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Andrewid the Android is a galaxy-known detective. Now he is preparing a defense against a possible attack by hackers on a major computer network.
In this network are n vertices, some pairs of vertices are connected by m undirected channels. It is planned to transfer q important messages via this network, the i-th of which must be sent from vertex s__i to vertex d__i via one or more channels, perhaps through some intermediate vertices.
To protect against attacks a special algorithm was developed. Unfortunately it can be applied only to the network containing directed channels. Therefore, as new channels can't be created, it was decided for each of the existing undirected channels to enable them to transmit data only in one of the two directions.
Your task is to determine whether it is possible so to choose the direction for each channel so that each of the q messages could be successfully transmitted.
安卓侦探安德鲁伊德是银河系闻名的侦探。目前,他正在为一个大型计算机网络可能遭受黑客攻击而准备防御措施。
该网络包含 n 个顶点,其中某些顶点对之间通过 m 条无向信道相连。计划通过该网络传输 q 条重要消息,其中第 i 条消息必须从顶点 si 经由一条或多条信道(可能经过若干中间顶点)发送至顶点 di。
为抵御攻击,专门开发了一种保护算法。遗憾的是,该算法仅适用于包含有向信道的网络。因此,在无法新建信道的前提下,决定对每条现有无向信道指定其唯一的数据传输方向(即将其定向为有向边)。
你的任务是判断:是否可以为每条信道恰当地指定方向,使得全部 q 条消息均能成功传输。
输入格式
The first line contains three integers n, m and q (1 ≤ n, m, q ≤ 2·105) — the number of nodes, channels and important messages.
Next m lines contain two integers each, v__i and u__i (1 ≤ v__i, u__i ≤ n, v__i ≠ u__i), that means that between nodes v__i and u__i is a channel. Between a pair of nodes can exist more than one channel.
Next q lines contain two integers s__i and d__i (1 ≤ s__i, d__i ≤ n, s__i ≠ d__i) — the numbers of the nodes of the source and destination of the corresponding message.
It is not guaranteed that in it initially possible to transmit all the messages.
第一行包含三个整数 n、m 和 q(1 ≤ n, m, q ≤ 2⋅105),分别表示节点数、信道数和重要消息数。
接下来的 m 行每行包含两个整数 vi 和 ui(1 ≤ vi, ui ≤ n,且 vi = ui),表示节点 vi 与 ui 之间存在一条信道。任意一对节点之间可能存在多条信道。
接下来的 q 行每行包含两个整数 si 和 di(1 ≤ si, di ≤ n,且 si = di),表示第 i 条消息的源节点与目的节点编号。
初始状态下,并不保证所有消息均能成功传输。
输出格式
If a solution exists, print on a single line "Yes" (without the quotes). Otherwise, print "No" (without the quotes).
如果存在解,在一行中输出“Yes”(不带引号)。否则,输出“No”(不带引号)。
输入输出样例
输入#1
4 4 2 1 2 1 3 2 3 3 4 1 3 4 2
输出#1
Yes
输入#2
3 2 2 1 2 3 2 1 3 2 1
输出#2
No
输入#3
3 3 2 1 2 1 2 3 2 1 3 2 1
输出#3
Yes
说明/提示
In the first sample test you can assign directions, for example, as follows: 1 → 2, 1 → 3, 3 → 2, 4 → 3. Then the path for for the first message will be 1 → 3, and for the second one — 4 → 3 → 2.
In the third sample test you can assign directions, for example, as follows: 1 → 2, 2 → 1, 2 → 3. Then the path for the first message will be 1 → 2 → 3, and for the second one — 2 → 1.
在第一个样例测试中,你可以如下分配边的方向:1 → 2、1 → 3、3 → 2、4 → 3。此时,第一条消息的路径为 1 → 3,第二条消息的路径为 4 → 3 → 2。
在第三个样例测试中,你可以如下分配边的方向:1 → 2、2 → 1、2 → 3。此时,第一条消息的路径为 1 → 2 → 3,第二条消息的路径为 2 → 1。
输入解题思路,AI测评打分。不知道怎么写?