Question:
I already know what card the first person will play in every round .. you have some cards on your hand .. ask how to win the most... the condition for victory is the ratio of size .. first, let's look at the partial order of the first digit (, T, J, Q, K,... if equal .. look at the partial order of the second (C, D, S, H...
Question:
If you can win... if you have enough edge... then run the maximum matching of the Bipartite Graph...
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 55#define MAXM 100005#define oo 100000007using namespace std; int n,A[MAXN][2],B[MAXN][2],match[MAXN]; bool g[MAXN][MAXN],used[MAXN];int turn(char c){ if (c>='2' && c<='9') return c-'2'; if (c=='T' || c=='C') return 8; if (c=='J' || c=='D') return 9; if (c=='Q' || c=='S') return 10; if (c=='K' || c=='H') return 11; return 12;}bool dfs(int x){ for (int i=1;i<=n;i++) if (!used[i] && g[x][i]) { used[i]=true; if (!match[i] || dfs(match[i])) { match[i]=x; return true; } } return false;}int getmax(){ int i,sum=0; memset(match,0,sizeof(match)); for (i=1;i<=n;i++) { memset(used,false,sizeof(used)); sum+=dfs(i); } return sum;}int main(){ int cases,i,j; char c; scanf("%d",&cases); while (cases--) { scanf("%d",&n); for (i=1;i<=n;i++) { do { c=getchar(); }while (c==' '|| c=='\n'); A[i][0]=turn(c); do { c=getchar(); }while (c==' '|| c=='\n'); A[i][1]=turn(c); } for (i=1;i<=n;i++) { do { c=getchar(); }while (c==' '|| c=='\n'); B[i][0]=turn(c); do { c=getchar(); }while (c==' '|| c=='\n'); B[i][1]=turn(c); } memset(g,false,sizeof(g)); for (i=1;i<=n;i++) for (j=1;j<=n;j++) if (B[i][0]>A[j][0] || (B[i][0]==A[j][0] && B[i][1]>A[j][1])) g[i][j]=true; printf("%d\n",getmax()); } return 0; }