CF690C1.Brain Network (easy)
普及-
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
One particularly well-known fact about zombies is that they move and think terribly slowly. While we still don't know why their movements are so sluggish, the problem of laggy thinking has been recently resolved. It turns out that the reason is not (as previously suspected) any kind of brain defect – it's the opposite! Independent researchers confirmed that the nervous system of a zombie is highly complicated – it consists of n brains (much like a cow has several stomachs). They are interconnected by brain connectors, which are veins capable of transmitting thoughts between brains. There are two important properties such a brain network should have to function properly:
- It should be possible to exchange thoughts between any two pairs of brains (perhaps indirectly, through other brains).
- There should be no redundant brain connectors, that is, removing any brain connector would make property 1 false.
If both properties are satisfied, we say that the nervous system is valid. Unfortunately (?), if the system is not valid, the zombie stops thinking and becomes (even more) dead. Your task is to analyze a given nervous system of a zombie and find out whether it is valid.
关于僵尸,一个广为人知的事实是:它们的行动和思维都极其迟缓。尽管我们至今仍不清楚其行动为何如此缓慢,但思维迟滞的问题最近已被解决。事实证明,原因并非如先前所猜测的那样——源于某种脑部缺陷;恰恰相反!独立研究人员证实,僵尸的神经系统极为复杂——它由 n 个大脑组成(类似于牛拥有多个胃)。这些大脑通过“脑连接器”相互连接,而脑连接器即为可在大脑之间传递思维的血管。为使该大脑网络正常运作,必须满足以下两个重要性质:
- 任意两个大脑之间均应能够交换思维(或许需借助其他大脑间接实现);
- 不应存在冗余的脑连接器,即:移除任意一条脑连接器都会导致性质 1 不再成立。
若同时满足上述两条性质,则称该神经系统为有效的。不幸的是(?),一旦系统无效,僵尸便会停止思考,从而变得(更加)死亡。你的任务是分析给定的僵尸神经系统,并判断其是否有效。
输入格式
The first line of the input contains two space-separated integers n and m (1 ≤ n, m ≤ 1000) denoting the number of brains (which are conveniently numbered from 1 to n) and the number of brain connectors in the nervous system, respectively. In the next m lines, descriptions of brain connectors follow. Every connector is given as a pair of brains a b it connects (1 ≤ a, b ≤ n, a ≠ b).
输入的第一行包含两个以空格分隔的整数 n 和 m(1 ≤ n, m ≤ 1000),分别表示大脑的数量(编号恰好为 1 到 n)以及神经系统中脑连接器的数量。接下来的 m 行描述了各个脑连接器。每个连接器由它所连接的两个大脑 a 和 b 组成(1 ≤ a, b ≤ n,且 a = b)。
输出格式
The output consists of one line, containing either yes or no depending on whether the nervous system is valid.
输出为一行,包含 yes 或 no,具体取决于神经系统是否有效。
输入输出样例
输入#1
4 4 1 2 2 3 3 1 4 1
输出#1
no
输入#2
6 5 1 2 2 3 3 4 4 5 3 6
输出#2
yes
输入解题思路,AI测评打分。不知道怎么写?