Selecting Courses 【最大匹配】

解决学生选课冲突问题,通过构建课程与上课时间的最大匹配模型,实现学生尽可能多地选择无时间冲突的课程。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Selecting Courses
Time Limit: 1000MS

Memory Limit: 65536K
Total Submissions: 8998

Accepted: 4005
Description
It is well known that it is not easy to select courses in the college, for there is usually conflict among the time of the courses. Li Ming is a student who loves study every much, and at the beginning of each term, he always wants to select courses as more as possible. Of course there should be no conflict among the courses he selects.

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?
Input
The input contains several cases. For each case, the first line contains an integer n (1 <= n <= 300), the number of courses in Li Ming’s college. The following n lines represent n different courses. In each line, the first number is an integer t (1 <= t <= 7*12), the different time when students can go to study the course. Then come t pairs of integers p (1 <= p <= 7) and q (1 <= q <= 12), which mean that the course will be taught at the q-th class on the p-th day of a week.
Output
For each test case, output one integer, which is the maximum number of courses Li Ming can select.
Sample Input
5
1 1 1
2 1 1 2 2
1 2 2
2 3 2 3 3
1 3 3
Sample Output
4

水题,以课程为匹配一方,以开始上课的时间为匹配另一方,求最大匹配
代码

#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#include<vector>
#include<set>
#define CLR(a,b) memset((a),(b),sizeof(a))
#define inf 0x3f3f3f3f
#define mod 100009
#define LL long long
#define MAXN  1000+10
#define MAXM 2000000+100
#define ll o<<1
#define rr o<<1|1
#define lson o<<1,l,mid
#define rson o<<1|1,mid+1,r
using namespace std;
void read(int &x){
    x=0;char c;
    while((c=getchar())<'0');
    do x=x*10+c-'0';while((c=getchar())>='0');
}
struct Edge{
    int from,to,next;
}edge[MAXM];
int head[MAXN],top;
int vis[MAXN],pipei[MAXN];
int n,m;
void addedge(int a,int b)
{
    Edge e={a,b,head[a]};
    edge[top]=e;head[a]=top++;
}
void init()
{
    memset(head,-1,sizeof(head));
    top=0;
    memset(pipei,0,sizeof(pipei));
}
void getmap()
{
    for(int i=1;i<=n;i++)
    {
        int num;
        cin>>num;
        while(num--)
        {
        int a,b;
        scanf("%d%d",&a,&b);
        addedge(i,(a-1)*12+b);  // 以开课时间和课程求最大匹配
        }
    }
}
int find(int x)
{
    for(int i=head[x];i!=-1;i=edge[i].next)
    {
        Edge e=edge[i];
        if(!vis[e.to])
        {
            vis[e.to]=1;
            if(!pipei[e.to]||find(pipei[e.to]))
            {
                pipei[e.to]=x;
                return 1;
            }
        }
    }
    return 0;
}
void solve()
{
    int sum=0;
    for(int i=1;i<=n;i++)
    {
        memset(vis,0,sizeof(vis));
        sum+=find(i);
    }
    printf("%d\n",sum);
}
int main()
{
    while(~scanf("%d",&n))
    {
        init();
        getmap();
        solve();
    }
    return 0;
}
主要分为四个角色,学生,企业,教师,管理员。 1.学生(求职者) 用户注册与登录:学生需注册并登录系统,完善个人信息(如姓名、性别、专业、年级等),以便企业进行简历筛选和匹配。 职位信息查询:学生可以按类别或关键词查询职位信息,了解企业背景和招聘要求。 简历管理:学生可以编辑和上传简历,包括基本信息、教育背景、在校情况、实习经历、技能特长等,方便企业查看。 职位收藏与留言:学生可以收藏感兴趣的职位,或在职位页面留言咨询,与企业进行初步沟通。 应聘管理:学生可以对心仪的职位发起应聘,查看应聘进度和结果。 个人中心:管理个人信息、查看收藏的职位和应聘记录等。 校园职位推荐:系统根据学生的专业、年级等信息,智能推荐符合其条件的校园职位。 校园宣讲会信息:查看校园内的企业宣讲会信息,学生可以在线报名参加。 校友互动:提供校友间的交流平台,分享求职经验和心得。 校园就业动态:查看校园内的就业动态和新闻,学生可以进行点赞、收藏以及评论等操作。 求职咨询:学生可以向教师发起在线咨询请求,实现实时聊天,描述自己的求职困惑或职业规划问题。 2.企业(招聘方) 企业注册与登录:企业需注册并登录系统,完善企业信息(如企业名称、经营范围、地址、联系方式等)。 职位信息发布:企业可以发布职位信息,包括岗位名称、职位描述、工作地点、薪资待遇、招聘人数等。 简历筛选与查看:企业可以查看学生投递的简历,进行初步筛选和评估。 应聘管理:企业可以查看应聘者的简历,安排面试,处理应聘请求(决定是否录用、以及给应聘者反馈)。 企业中心:管理企业信息、查看发布的职位信息和应聘情况等。 校园专属招聘活动:企业可以发布针对校园学生的专属招聘活动信息,吸引更多符合需求的学生。 校园宣讲会发布:企业可以在系统中报名发布校园宣讲会。 推荐学生接收:企业可以在系统中查看教师推荐的学生信息,包括学生的姓名、专业、年级、技能特长、实习经历、简历等关键信息,还可教师对学生的推荐理由和简短评价。 3.教师 推荐学生:老师可以根据学生的学业成绩、实习经历、技能特长等,向企业推荐合适的学生。推荐时,老师可以附上对学生的简短评价或推荐理由,推荐完成后可以查看自己推荐过的学生记录(包括推荐时间、企业反馈等)。 就业情况跟踪:老师可以统计自己学生的就业情况,包括录用的企业名称、薪资情况等信息。 求职咨询辅导:老师可以为学生解答求职困惑以及职业规划咨询建议。 4. 管理员 用户管理:查看并管理注册用户,包括学生和企业,审核企业账号。 招聘职位信息管理:审核、编辑和删除职位信息,确保信息的准确性和合规性。 应聘管理:管理应聘者的简历以及处理应聘请求等操作。 招聘活动管理:审核、发布和管理校园内的招聘活动信息,如宣讲会、招聘会等,还可管理相应的报名信息。 数据统计与分析:统计和分析学生求职、企业招聘的数据,为就业部门提供决策支持。 系统管理:管理系统设置、就业指导信息、校友互动信息等。 校园就业动态管理:发布校园内的就业动态和新闻,让学生及时了解就业市场变化。 其他功能:求职咨询辅导管理、推荐学生管理等.生成各个角色的时序图
最新发布
03-29
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值