Problems
Contests
Events
Topic
IDE
PacketHub
Login
Description
Editorial
My Submission
1101.Forming Teams
Look up all submission
Status
Time
Memory
Lang.
Submit Date
1101.Forming Teams
Time Limit:1000MS Memory Limit:65535KB
Description
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.
Input
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*.
Output
Print a single integer --- the minimum number of students you will have to send to the bench in order to start the game.
Sample test
Sample input
5 4 1 2 2 4 5 3 1 4
Sample output
1
Note
input 6 2 1 4 3 4 output 0 ##### input 6 6 1 2 2 3 3 1 4 5 5 6 6 4 output 2
Tags
graph
dfs
Post editorial
Editorials
GNU C++ 9.3.0
GNU C 9.3.0
Java 1.8
Python 3.8.4
Lua 5.3
GO 1.12.4
JS - (nodejs 10.19.0)
Login before submit
Test Input
Test Output
5 4 1 2 2 4 5 3 1 4
Please run you code firstly.
Console
IDE Setting
字体设置
调整适合你的字体大小。
12px
13px
14px
15px
16px
18px
20px
主题设置
切换不同的代码编辑器主题,选择适合你的语法高亮。
Visual Studio
Visual Studio Dark
High Contrast Dark
行宽限制
设置每一行代码的最大字符个数,设置为0则不限制。
0
80
100
120