Divide Groups
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1835 Accepted Submission(s): 657
Problem Description
Input
The input contains several test cases, terminated by EOF. Each case starts with a positive integer n (2<=n<=100), which means the number of people joining in the event. N lines follow. The i-th line contains some integers which are the id of students that the i-th student knows, terminated by 0. And the id starts from 1.
Output
If divided successfully, please output "YES" in a line, else output "NO".
Sample Input
3 3 0 1 0 1 2 0
Sample Output
YES
#include#include #include #include #include using namespace std;const int Max=111;int G[Max][Max];int path[Max][Max],book[Max],color[Max],book1[Max];int n;bool dfs(int u,int co){// cout< <<" "< <<" "< <