栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

poj 2062 Card Game Cheater

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

poj 2062 Card Game Cheater

#include<cstdio>#include<cstring>#include<algorithm>using namespace std;bool g[30][30],chk[30];int link[30],n;bool findpath(int x){    for(int y=0;y<n;y++)    {        if(g[x][y]&&!chk[y])        { chk[y]=true; if(link[y]==-1||findpath(link[y])) {     link[y]=x;     return true; }        }    }    return false;}int maxmatch(){    memset(link,-1,sizeof(link));    int ret=0;    for(int x=0;x<n;x++)    {        memset(chk,false,sizeof(chk));        if(findpath(x)) ret++;    }    return ret;}int op[150];bool small(char s1[],char s2[]){    if(op[s1[0]]!=op[s2[0]])        return op[s1[0]]<op[s2[0]];    else        return op[s1[1]]<op[s2[1]];}int main(){    for(int i=2;i<=9;i++)        op[i+'0']=i;    op['T']=10;op['J']=11;op['Q']=12;op['K']=13;op['A']=14;    op['C']=1;op['D']=2;op['S']=3;op['H']=4;    int T;    for(scanf("%d",&T);T;T--)    {        scanf("%d",&n);        memset(g,false,sizeof(g));        char s1[30][3],s2[30][3];        for(int i=0;i<n;i++) scanf("%s",s1[i]);        for(int i=0;i<n;i++)        { scanf("%s",s2[i]); for(int j=0;j<n;j++)     if(small(s1[j],s2[i]))         g[i][j]=true;        }        printf("%dn",maxmatch());    }    return 0;}
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/373318.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号