Problem B
Chopsticks
Michael is having some friends over for Chinese New Year tomorrow! There’s one issue though: he forgot to buy new chopsticks! Fortunately, he found a drawer of random chopsticks in his kitchen to use - he just has to pair them up. He can’t pair up two chopsticks unless both of them are the same material (for luck!) and are the same length. Will he have enough pairs for everyone?
Input
The first line contains $2$ integers $n$ $m$, representing the number of people going to the party ($1 \le n \le 1\, 000$) and the number of chopsticks in his drawer ($1 \le m \le 10\, 000$). The next $m$ lines contain two space-separated integers each, $x_1$ $x_2$. The first number, $x_1$, being the the type of chopstick ($1 \le x_1 \le 1\, 000$) and the second number, $x_2$, being the length of the chopstick, in millimeters ($50 \le x_2 \le 500$).
Output
The output is a single string, ’yes’ or ’no’, to indicate whether Michael is able to find enough pairs of chopsticks or not.
Sample Input 1 | Sample Output 1 |
---|---|
2 6 3 112 1 213 2 180 3 213 2 180 3 213 |
yes |