ENG  RUSTimus Online Judge
Online Judge
Задачи
Авторы
Соревнования
О системе
Часто задаваемые вопросы
Новости сайта
Форум
Ссылки
Архив задач
Отправить на проверку
Состояние проверки
Руководство
Регистрация
Исправить данные
Рейтинг авторов
Текущее соревнование
Расписание
Прошедшие соревнования
Правила
вернуться в форум

Общий форум

Pairs
Послано typedef 26 янв 2010 13:59
Hello! I have the following task:

I have 2 groups: boys and girls. Each boy has a list of girls' names. The list contains girls he want to dance with. Each girl has the same list with boys' names. I khow, that the quantity of girls is not less, than the quantity of boys. I have to answer the question: are there pairs boy-girl (in each pair the guys want to dance with each other) when all girls will dance? Each list is not empty.

Please, give me an idea to solve this problem. Thank you.
Re: Pairs
Послано Baurzhan 26 янв 2010 15:09
0) If girls > boys, the answer, obviously, NO.

If girls==boys
1)Build graph with two parts: boys and girls.
2) If some girl(i) want to dance with some boy(j) you add edge (i,j) with weight 1 into your graph.
3) Find maximal biparite matching (if you can't look it in google)
4) If MaxBipMatching==girls count the answer is yes. Otherwise NO.