HDOJ 3729 - I'm Telling the Truth 水二分图最大匹配
来源:互联网 发布:老司机 种子 知乎 编辑:程序博客网 时间:2024/06/07 10:45
题意:
每个学生说出其分数在哪个名次区间...问最多有多少个学生可能说真话...并且按字典序大的输出
题解:
应该是2010年天津区域赛的签到题...将每个学生和其可能的分数都建边..注意..用邻接表来建....为了保证字典序最大..那么反过来.从最后一个学生开始往前面找...
Program:
#include<iostream>#include<stdio.h>#include<algorithm>#include<cmath>#include<stack>#include<string.h>#include<queue>#define ll long long#define esp 1e-5#define MAXN 65#define MAXM 50000000#define oo 100000007using namespace std; struct node{ int x,y,next;}line[MAXM];int Lnum,_next[MAXN],match[100005];bool used[100005],ok[MAXN];void addline(int x,int y){ line[++Lnum].next=_next[x],_next[x]=Lnum,line[Lnum].x=x,line[Lnum].y=y;}bool dfs(int x){ for (int k=_next[x];k;k=line[k].next) { int y=line[k].y; if (used[y]) continue; used[y]=true; if (!match[y] || dfs(match[y])) { match[y]=x; return true; } } return false; }int getmax(int n){ int sum=0; memset(match,0,sizeof(match)); for (int i=n;i>=1;i--) { memset(used,false,sizeof(used)); sum+=dfs(i); } return sum; }int main() { int cases,n,x,i; scanf("%d",&cases); while (cases--) { scanf("%d",&n); Lnum=0,memset(_next,0,sizeof(_next)); for (x=1;x<=n;x++) { int l,r; scanf("%d%d",&l,&r); for (i=l;i<=r;i++) addline(x,i); } printf("%d\n",getmax(n)); memset(ok,false,sizeof(ok)); for (i=1;i<=100000;i++) ok[match[i]]=true; bool f=true; for (i=1;i<=n;i++) if (ok[i]) { if (f) printf("%d",i); else printf(" %d",i); f=false; } printf("\n"); } return 0; }
- HDOJ 3729 - I'm Telling the Truth 水二分图最大匹配
- 【HDOJ 3729】 I'm Telling the Truth (二分图最大匹配)
- hdu3729 I'm Telling the Truth(二分图最大匹配)
- HDU3729 I'm Telling the Truth(二分图最大匹配)
- hdu 3729 I'm Telling the Truth 二分图匹配
- hdu 3729 I'm Telling the Truth(二分图匹配)
- hdu 3729 I'm Telling the Truth(二分图最大匹配,字典序最大输出)
- HDU 3729 I'm Telling the Truth -- 二分图最大匹配 输出方案
- hdu 3729 I'm Telling the Truth(二分图最大匹配)
- 二分图的最大匹配-hdu-3729-I'm Telling the Truth
- 二分图的最大匹配-hdu-3729-I'm Telling the Truth
- HDU 3729 I'm Telling the Truth(二分图最大匹配+结果输出)
- HDU 3729 I'm Telling the Truth(二分图最大匹配)
- HDU 3729 I'm Telling the Truth(二分图最大匹配)
- HDU 3729 I'm Telling the Truth(二分图最大匹配)
- hdu 3729 I'm Telling the Truth【二分匹配】
- hdu_3729 I'm Telling the Truth 二分图匹配
- UVALive 5033 I'm Telling the Truth 二分图匹配
- Fedora中如何创建文件夹和创建文件
- JDBC为什么要使用PreparedStatement而不是Statement
- linux踢出远程登录用户命令
- 关于获取gridview里点击时获取对应的id号
- 读书笔记3:Head First设计模式——装饰者模式
- HDOJ 3729 - I'm Telling the Truth 水二分图最大匹配
- lsof
- 专家看好甲骨文-微软云计算合作计划
- 如何获取ApplicationContext
- PHP小镇微信平台开通,欢迎大家关注!
- 传微软将于7月1日宣布实施大规模重组
- 常量指针 和 指针常量
- sqlserver 读取类
- tput