Title Link: http://acm.hdu.edu.cn/showproblem.php?pid=1528
Test instructions is for two people with n cards. The second person knows the sequence of the first person's cards;
Then as much as possible to make their own higher points, to seek the highest score;
Is the other side to take a card out of his own to get a bigger than his 1 points, if the same as the Peach > Spades > Blocks > Plum to compare;
The maximum matching of the building map;
#include <stdio.h>#include<iostream>#include<string.h>#include<algorithm>#include<math.h>using namespacestd;#defineN 220intN, Maps[n][n], vis[n], used[n];structnode{intV,s;///V is the value of solitaire, S type 1: Plum 2: Block 3: Spades 4: Red Peach;} A[n], b[n];voidChangeCharS[], node &a)///the incoming address can change its value;{ if(s[0]<='9'&&s[0]>='2') a.v=s[0]-'0'; if(s[0]=='A') a.v= -;///A is the largest card; ;;;; if(s[0]=='T') a.v=Ten; if(s[0]=='J') a.v= One; if(s[0]=='Q') a.v= A; if(s[0]=='K') a.v= -; if(s[1]=='H') a.s=4; if(s[1]=='S') a.s=3; if(s[1]=='D') a.s=2; if(s[1]=='C') a.s=1;}BOOLFind (intu) { for(intI=1; i<=n; i++) { if(!vis[i] &&Maps[u][i]) {Vis[i]=1; if(!used[i] | |Find (Used[i])) {Used[i]=T; return true; } } } return false;}intMain () {intT; Chars[ One]; scanf ("%d", &T); while(t--) {memset (A,0,sizeof(a)); memset (b,0,sizeof(b)); memset (Maps,0,sizeof(maps)); memset (Used,0,sizeof(used)); scanf ("%d", &N); for(intI=1; i<=n; i++) {scanf ("%s", s); Change (S, A[i]); } for(intI=1; i<=n; i++) {scanf ("%s", s); Change (S, B[i]); for(intj=1; j<=n; J + +)///establish the relationship between B and a, when 1 indicates the card of the first person of the second man's card; { if(b[i].v>a[j].v) Maps[i][j]=1; if(B[I].V==A[J].V && b[i].s>a[j].s) Maps[i][j]=1; } } intans=0; for(intI=1; i<=n; i++) {memset (Vis,0,sizeof(VIS)); if(Find (i)) ans++; } printf ("%d\n", ans); } return 0;}
View Code
Card Game Cheater---hdu1528 (binary match)