There are 12 classes every day, and 7 days every week. There are hundreds of courses in the college, and teaching a course needs one class each week. To give students more convenience, though teaching a course needs only one class, a course will be taught several times in a week. For example, a course may be taught both at the 7-th class on Tuesday and 12-th class on Wednesday, you should assume that there is no difference between the two classes, and that students can select any class to go. At the different weeks, a student can even go to different class as his wish. Because there are so many courses in the college, selecting courses is not an easy job for Li Ming. As his good friends, can you help him?
#include<memory.h>
#include<iostream>
#define LEFT_MAX 301
#define RIGHT_MAX 12*7
bool useif[RIGHT_MAX];
int link[RIGHT_MAX];
int left_num,right_num=7*12;
bool array[LEFT_MAX][RIGHT_MAX];
bool can(int t) {
int i;
for(i=0;i<right_num;i++)
{
if(!useif[i]&&array[t][i])
{
useif[i]=true;
if(link[i]==-1||can(link[i]))
{
link[i]=t;
return true;
}
}
}
return false;
}
int main()
{
int i,k,num,temp,day,course;
while(scanf("%d/n",&left_num)!=-1)
{
memset(link,0xFF,sizeof(link));
memset(array,0,sizeof(array));
num=0;
for(i=0;i<left_num;i++)
{
scanf("%d",&temp);
for(k=0;k<temp;k++)
{
scanf("%d",&day);
scanf("%d",&course);
array[i][12*(day-1)+course-1]=true;
}
}
for(i=0;i<left_num;i++)
{
memset(useif,0,sizeof(useif));
if(can(i))
num++;
}
printf("%d/n",num);
}
return 1;
}