POJ 2062 Card Game Cheater

  题意:两个人打牌,牌的大小按照2,3,4...9,T,J,Q,K,A排序,如果点数相等就按照H>S>D>C的花色排序。告诉你第一个人的手牌,让你安排第二个人的手牌,使得得分最大(按照顺序依次比较每张牌大小)

 1 #include <iostream>
 2 #include <algorithm>
 3 #include <queue>
 4 using namespace std;
 5 int dot[300];
 6 int InputNum,NumOfCards,point;
 7 int Adm[26],Eve[26];
 8 char str1,str2;//牌的点数和花型
 9 void init();
10 void process();
11 int main()
12 {
13     //freopen("D:\\t.txt","r",stdin);
14     init();
15     process();
16     return 0;
17 }
18 void init(){//对数据进行初始化,将牌数*10
19     dot[‘T‘] = 100;dot[‘J‘] = 110;dot[‘Q‘] = 120;dot[‘K‘] = 130;dot[‘A‘] = 140;
20     for(int m = 2;m <= 9;m++){
21         dot[m + ‘0‘] = m * 10;
22     }
23     dot[‘H‘] = 4;dot[‘S‘] = 3;dot[‘D‘] = 2;dot[‘C‘] = 1;
24 }
25 void process(){
26     while(cin>>InputNum){
27         for(int i = 0;i < InputNum;i++){
28             cin>>NumOfCards;
29             point = 0;
30             //发牌
31             for(int k = 0;k < NumOfCards;k++){
32                 cin>>str1>>str2;
33                 Adm[k]= dot[str1] + dot[str2];//将牌数扩大十倍,加上花色
34             }
35             for(int j = 0;j < NumOfCards;j++){
36                 cin>>str1>>str2;
37                 Eve[j] = dot[str1] + dot[str2];
38             }
39             //
40             sort(Adm,Adm + NumOfCards);//将两个人的牌数按升序排列
41             sort(Eve,Eve + NumOfCards);
42             for(int i = 0, j = 0;i < NumOfCards&&j < NumOfCards;){
43                 if(Eve[i] > Adm[j]){
44                     point++;
45                     i++;j++;
46                 }
47                 else i++;
48             }//将两个人的牌按升序排列之后,进行比较
49        /*比如adm[3]={1,2,3},eve[3] = {1,2,3};
50        第一次adm[0] = eve[0]
51        然后用eve[1]与adm[0]比较,eve[1]>adm[0];
52        eve[2]>adm[1];
53        就能求出eve胜adm多少次了*/
54             cout<<point<<endl;
55         }
56     }
57 }
时间: 2024-11-06 22:21:01

POJ 2062 Card Game Cheater的相关文章

Card Game Cheater(贪心+二分匹配)

Card Game Cheater Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 1566    Accepted Submission(s): 822 Problem Description Adam and Eve play a card game using a regular deck of 52 cards. The rule

HDOJ 1528 Card Game Cheater

简单二分图匹配.... Card Game Cheater Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 1073    Accepted Submission(s): 565 Problem Description Adam and Eve play a card game using a regular deck of 52 ca

hdu----(1528)Card Game Cheater(最大匹配/贪心)

Card Game Cheater Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 1272    Accepted Submission(s): 675 Problem Description Adam and Eve play a card game using a regular deck of 52 cards. The rule

HDU 1528 Card Game Cheater

Card Game Cheater Problem Description Adam and Eve play a card game using a regular deck of 52 cards. The rules are simple. The players sit on opposite sides of a table, facing each other. Each player gets k cards from the deck and, after looking at

HDOJ 题目1528 Card Game Cheater(二分图最小点覆盖)

Card Game Cheater Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 1357    Accepted Submission(s): 722 Problem Description Adam and Eve play a card game using a regular deck of 52 cards. The rul

(hdu step 6.3.5)Card Game Cheater(匹配的最大数:a与b打牌,问b赢a多少次)

称号: Card Game Cheater Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 103 Accepted Submission(s): 74   Problem Description Adam and Eve play a card game using a regular deck of 52 cards. The rules

(hdu step 6.3.5)Card Game Cheater(最大匹配数:a与b打牌,问b能赢a多少次)

题目: Card Game Cheater Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 103 Accepted Submission(s): 74   Problem Description Adam and Eve play a card game using a regular deck of 52 cards. The rules

POJ 2062 HDU 1528 ZOJ 2223 Card Game Cheater

水题,感觉和田忌赛马差不多 #include<cstdio> #include<cstring> #include<cmath> #include<algorithm> using namespace std; struct P1 { int Num; int Hua; } Play1[30]; struct P2 { int Num; int Hua; } Play2[30]; bool cmp1(const P1&a,const P1&b

HDU 1528 Card Game Cheater(打扑克)

Description: Adam and Eve play a card game using a regular deck of 52 cards. The rules are simple. The players sit on opposite sides of a table, facing each other. Each player gets k cards from the deck and, after looking at them, places the cards fa