source
int64 2
2
| difficulty
int64 7
25
| name
stringlengths 9
60
| description
stringlengths 164
7.12k
| public_tests
dict | private_tests
dict | cf_rating
int64 0
3.5k
| cf_points
float64 0
4k
|
---|---|---|---|---|---|---|---|
2 | 9 | 690_C1. Brain Network (easy) | 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:
1. It should be possible to exchange thoughts between any two pairs of brains (perhaps indirectly, through other brains).
2. 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.
Input
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).
Output
The output consists of one line, containing either yes or no depending on whether the nervous system is valid.
Examples
Input
4 4
1 2
2 3
3 1
4 1
Output
no
Input
6 5
1 2
2 3
3 4
4 5
3 6
Output
yes | {
"input": [
"6 5\n1 2\n2 3\n3 4\n4 5\n3 6\n",
"4 4\n1 2\n2 3\n3 1\n4 1\n"
],
"output": [
"yes\n",
"no\n"
]
} | {
"input": [
"10 9\n2 3\n6 8\n10 1\n1 8\n6 7\n8 7\n10 5\n7 10\n2 5\n",
"2 1\n1 2\n",
"3 2\n1 2\n2 3\n",
"10 9\n6 5\n9 2\n4 7\n2 3\n7 3\n3 4\n10 6\n1 2\n5 8\n",
"8 7\n6 2\n1 5\n4 8\n4 7\n6 7\n8 3\n8 1\n",
"3 3\n2 1\n1 3\n3 2\n",
"10 9\n3 2\n4 1\n6 1\n7 1\n9 2\n6 9\n5 2\n7 9\n3 7\n",
"200 5\n93 101\n199 164\n14 94\n115 61\n106 156\n",
"9 8\n1 2\n2 3\n3 4\n4 1\n5 6\n6 7\n7 8\n8 9\n"
],
"output": [
"no\n",
"yes\n",
"yes\n",
"no\n",
"yes\n",
"no\n",
"no\n",
"no\n",
"no\n"
]
} | 1,300 | 0 |