【图论-二分图】学生的住宿
Time Limit:1000MS Memory Limit:65536K
Description
有n个学生,有m对人是认识的,每一对认识的人能分到一间房,问能否把n个学生分成两部分,每部分内的学生互不认识,而两部分之间的学生认识。如果可以分成两部分,就算出房间最多需要多少间,否则就输出No。
There are a group of students. Some of them may know each other, while others don't. For example, A and B know each other, B and C know each other. But this may not imply that A and C know each other.
Now you are given all pairs of students who know each other. Your task is to divide the students into two groups so that any two students in the same group don't know each other.If this goal can be achieved, then arrange them into double rooms. Remember, only paris appearing in the previous given set can live in the same room, which means only known students can

该博客探讨了如何使用图论中的二分图概念解决学生住宿问题。给定一组认识的学生,任务是将他们分成两组,使得同一组内的学生互不认识,同时确保每对认识的学生可以住在同一间房。博客通过实例和代码展示了如何判断一个图是否为二分图,并求出最大匹配数量,以确定最多能安排多少对认识的学生同住。
最低0.47元/天 解锁文章
2855

被折叠的 条评论
为什么被折叠?



