CF216B.Forming Teams
普及+/提高
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
One day n students come to the stadium. They want to play football, and for that they need to split into teams, the teams must have an equal number of people.
We know that this group of people has archenemies. Each student has at most two archenemies. Besides, if student A is an archenemy to student B, then student B is an archenemy to student A.
The students want to split so as no two archenemies were in one team. If splitting in the required manner is impossible, some students will have to sit on the bench.
Determine the minimum number of students you will have to send to the bench in order to form the two teams in the described manner and begin the game at last.
一天,有 n 名学生来到体育场。他们想踢足球,为此需要分成若干支队伍,且每支队伍的人数必须相等。
我们知道,这群学生中存在“宿敌”关系。每名学生最多有两名宿敌;此外,若学生 A 是学生 B 的宿敌,则学生 B 也是学生 A 的宿敌。
学生们希望分队时,任意两名宿敌都不在同一个队中。如果无法按上述要求完成分队,则部分学生将不得不坐在替补席上。
请确定:为满足上述条件并最终成功组队开始比赛,最少需要安排多少名学生坐上替补席。
输入格式
The first line contains two integers n and m (2 ≤ n ≤ 100, 1 ≤ m ≤ 100) — the number of students and the number of pairs of archenemies correspondingly.
Next m lines describe enmity between students. Each enmity is described as two numbers a__i and b__i (1 ≤ a__i, b__i ≤ n, a__i ≠ b__i) — the indexes of the students who are enemies to each other. Each enmity occurs in the list exactly once. It is guaranteed that each student has no more than two archenemies.
You can consider the students indexed in some manner with distinct integers from 1 to n.
第一行包含两个整数 n 和 m(2≤n≤100,1≤m≤100)——分别表示学生的数量和宿敌对的数量。
接下来的 m 行描述学生之间的宿敌关系。每对宿敌关系由两个整数 ai 和 bi(1≤ai,bi≤n,且 ai=bi)表示——即互为宿敌的两名学生的编号。每对宿敌关系在列表中恰好出现一次。保证每名学生至多有两个宿敌。
你可以将学生用从 1 到 n 的互不相同的整数进行编号。
输出格式
Print a single integer — the minimum number of students you will have to send to the bench in order to start the game.
输出一个整数——为开始游戏而必须送往替补席的最少学生人数。
输入输出样例
输入#1
5 4 1 2 2 4 5 3 1 4
输出#1
1
输入#2
6 2 1 4 3 4
输出#2
0
输入#3
6 6 1 2 2 3 3 1 4 5 5 6 6 4
输出#3
2
输入解题思路,AI测评打分。不知道怎么写?