306517: CF1209D. Cow and Snacks
Memory Limit:256 MB
Time Limit:2 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
Cow and Snacks
题意翻译
$n$ 种花,$k$ 个客人,每个人喜欢两种编号不同的花。但是每种花在花店里只有一束。 客人按顺序进入花店,会买走所有她喜欢且仍在店铺里的花。如果一个客人买不到任何一束花,那么她就会十分沮丧导致变成肥宅。现在你可以自己安排这 $k$ 个人的顺序,使得肥宅的数量最小。 翻译 by @皎月半洒花。题目描述
The legendary Farmer John is throwing a huge party, and animals from all over the world are hanging out at his house. His guests are hungry, so he instructs his cow Bessie to bring out the snacks! Moo! There are $ n $ snacks flavors, numbered with integers $ 1, 2, \ldots, n $ . Bessie has $ n $ snacks, one snack of each flavor. Every guest has exactly two favorite flavors. The procedure for eating snacks will go as follows: - First, Bessie will line up the guests in some way. - Then in this order, guests will approach the snacks one by one. - Each guest in their turn will eat all remaining snacks of their favorite flavor. In case no favorite flavors are present when a guest goes up, they become very sad. Help Bessie to minimize the number of sad guests by lining the guests in an optimal way.输入输出格式
输入格式
The first line contains integers $ n $ and $ k $ ( $ 2 \le n \le 10^5 $ , $ 1 \le k \le 10^5 $ ), the number of snacks and the number of guests. The $ i $ -th of the following $ k $ lines contains two integers $ x_i $ and $ y_i $ ( $ 1 \le x_i, y_i \le n $ , $ x_i \ne y_i $ ), favorite snack flavors of the $ i $ -th guest.
输出格式
Output one integer, the smallest possible number of sad guests.
输入输出样例
输入样例 #1
5 4
1 2
4 3
1 4
3 4
输出样例 #1
1
输入样例 #2
6 5
2 3
2 1
3 4
6 5
4 5
输出样例 #2
0