[POJ1469 COURSES]
[题目来源]Southeastern Europe 2000:
[关键字]:图论
[题目大意]:让每个学生代表一门课程,且每个课程只有一个学生代表行不行?
//=====================================================================================================
[分析]:如果二分图最大匹配达到了学生数则可行否则不可行
[代码]:
1 program Project1; 2 var 3 n, p, tc: longint; 4 map: array[0..1000,0..1000] of boolean; 5 b: array[0..1000] of boolean; 6 link: array[0..1000] of longint; 7 8 procedure init; 9 var10 i, j, t, y: longint;11 begin12 readln(p,n);13 fillchar(map,sizeof(map),false);14 for i := 1 to p do15 begin16 read(t);17 for j := 1 to t do18 begin19 read(y);20 map[i,p+y] := true;21 map[p+y,i] := true;22 //writeln(i,'',y);23 end;24 end;25 { for i := 1 to n+p do26 for j := 1 to n+p do writeln(i,' ',j,' ',map[i,j]); }27 end;28 29 function dfs(k: longint):boolean;30 var31 i: longint;32 begin33 for i := 1 to n+p do34 if (map[k,i]) and (not b[i]) then35 begin36 b[i] := true;37 if (link[i] = 0) or (dfs(link[i])) then38 begin39 link[i] := k;40 exit(true);41 end;42 end;43 exit(false);44 end;45 46 procedure work;47 var48 i, max: longint;49 begin50 fillchar(link,sizeof(link),0);51 max := 0;52 for i := 1 to p do53 begin54 fillchar(b,sizeof(b),false);55 if dfs(i) then inc(max);56 end;57 // writeln(max);58 // for i := 1 to n do write(link[i],'');59 if max = p then writeln('YES') else writeln('NO');60 end;61 62 begin63 readln(tc);64 while tc > 0 do65 begin66 init;67 work;68 dec(tc);69 end;70 end.
转载于:https://www.cnblogs.com/procedure2012/archive/2011/11/02/2232828.html
[POJ1469 COURSES]相关推荐
- poj 1469 COURSES
2019独角兽企业重金招聘Python工程师标准>>> COURSES Time Limit: 1000MS Memory Limit: 10000K Total Submissio ...
- 深度学习课程Deep Learning Courses
深度学习是一个快速成长的人工智能领域.它越来越多地用于提供接近人类的水平精度图像分类,语音识别,自然语言处理,情感分析,推荐引擎等.应用领域包括面部识别,场景检测,先进的医疗和制药研究,以及车辆的自动 ...
- 计算机科学与教育信息化国际会议,A Courses Ontology System for Computer Science Education...
摘要: A computer knowledge system plays a crucial role in computer education owing to the diversificat ...
- TZOJ 3030 Courses(二分图匹配)
描述 Consider a group of N students and P courses. Each student visits zero, one or more than one cour ...
- 【HDU - 1083 】Courses (二分图)
题干: Consider a group of N students and P courses. Each student visits zero, one or more than one cou ...
- Stanford University courses of computer science department(斯坦福计算机系课程设置)
斯坦福学科目前分为7个department:Business, Earth, Education, Engineering, Humanities & Sciences, Law, Medic ...
- MOOC(massive open online courses)
大型开放式网络课程,即MOOC(massive open online courses).2012年,美国的顶尖大学陆续设立网络学习平台,在网上提供免费课程,Coursera.Udacity.edX三 ...
- Overview of technical writing courses | 技术写作课程概览
The following table summarizes the technical writing courses: 本技术写作课程目录如下: Title标题 Summary摘要 Pre-Cla ...
- 麻省理工学院的网站在线课程学习(http://ocw.mit.edu/courses/)
(http://ocw.mit.edu/courses/)
最新文章
- Java虚拟机学习(2):垃圾收集算法
- Kubernetes 入门(1)基本概念
- 【深度学习】深入理解Batch Normalization批归一化
- ajax数据显示,使用js通用模板
- 【PHP+MySQL学习笔记】php操作MySQL数据库中语句
- data-packed volume container - 每天5分钟玩转 Docker 容器技术(43)
- BestCoder Round #70
- JavaScript DOM高级程序设计 5动态修改样式和层叠样式表1(源代码)--我要坚持到底!...
- 读懂人工智能、机器学习、深度学习、大数据,自然语言处理……
- 数学建模方法自己归纳总结(建模参考用,包含相应例题以及MATLAB代码)
- 软件工程—需求分析阶段
- 解决out.print()爆红问题
- 布局java ee企业级开发_布局JavaEE企业级开发:寻觅框架和开发模式的完美整合...
- java 多线程 超时_【Java】Java多线程任务超时结束的5种实现方法
- Gibberish 本地化插件学习
- iOS 一步步带你实践组件二进制方案
- 绕开JS验证的方法汇总
- 个人日常开发工具、问题收集
- 奇点临近:互联网经济的供给侧革命和全球货币政策的新格林斯潘之谜
- 海思平台上USB WIFI的移植与局域网无线调试和视频流预览-第5/11季视频课程-朱有鹏-专题视频课程...