浙江财经大学第十五届大学生程序设计竞赛------B 烦恼先生打麻将
问题 B: B - 烦恼先生打麻将
时间限制: 1 Sec 内存限制: 256 MB提交: 8 解决: 5
[提交][状态][讨论版]
题目描述

输入
6 6
Z D 1S 1S 9W 5W 2S 6S 2W 1S X B 2W 1W 7W 1T 6W 3T B BB 4S 3T 8W X 3T 4T 5T 9T 8T 2W B 5W 7W Z 9W B 9T 3S 7W 9S 8T 6W F 4T 9W 4T D 2T 2T 9T 7W 7S 4T 4S 3W N 9T BB 7S X 1S 5T 5S 5S 3W 7S 2S 8S 3T 8S 1W 1T 6T D 2S 8W 5W 5T 6T 4S 3W 9W 8W N 2W D 7S 1W 1T 1W 8W N 4W 5S 3S F BB 6T 4S Z 2T N 6W 5S 9S 7T 3S 8S 4W 9S 6S 6T 7T 5W 4W 8T 1T F 8S X 3W Z 3S 6W 9S 5T 7T 8T F 2S 4W 6S 2T BB 6S 7T
Z D 1S 1S 9W 5W 2S 6S 2W 1S X B 2W 1W 7W 1T 6W 3T B BB 4S 3T 8W X 3T 4T 5T 9T 8T 2W B 5W 7W Z 9W B 9T 3S 7W 9S 8T 6W F 4T 9W 4T D 2T 2T 9T 7W 7S 4T 4S 3W N 9T BB 7S X 1S 5T 5S 5S 3W 7S 2S 8S 3T 8S 1W 1T 6T D 2S 8W 5W 5T 6T 4S 3W 9W 8W N 2W D 7S 1W 1T 1W 8W N 4W 5S 3S F BB 6T 4S Z 2T N 6W 5S 9S 7T 3S 8S 4W 9S 6S 6T 7T 5W 4W 8T 1T F 8S X 3W Z 3S 6W 9S 5T 7T 8T F 2S 4W 6S 2T BB 6S 7T
输出
#1:
9T BB 7S X 6T D 2S 1W N 9S
4W 7T 6W 8T BB D 9W 2W 2W 6W
4S 3T 8T 7W
#2:
3T 8S 1W 1T 2W D 7S 1W 2T N
6W 5S 8S 6T 8T X 3S 7T 2T Z
1S 6S
#3:
3W 7S 2S 8S 3W 9W 8W N BB 6T
4S Z 3S 6S 4W 8S Z 5T 2S 6S
7T 1S 2S X
#4:
1S 5T 5S 5S 5W 5T 6T 4S 4W 5S
3S F 7T 5W F 3W F 4W 6S 5W
1S 1W 4T
样例输入
4 1
BB BB BB BB B B B B D 2W 2W 2W D D D 1W N X 1W 8W F 8W 8T 2T 4W 6T X 1S N N Z 1W 9T 1S 8T 1T 3T 2T 6S 9S 5S 5S 2W 3W X X 1W 1W 6W 2S 8S 4S 2S F 8S 4T 9W 5W Z 9T 1S 3W 6S 5W 4W 3S 6W 3S 4S 3T 5T 5S 8S 8W 4T 7W 5T Z 4T 7S 2T 3T 6T 7T 9S 4S 2S 7T 3S 2T 3T 9W F 3W 8T 9W 1T 3W 6T 7S 9T 4T 9S 7T N 5W 7T 1T 6S 8W 9T 8T 2S 8S 7W 5S 4W 6T 4S 9S 6S 3S 9W 6W Z 7S 1T 7W 5T 5W 1S 6W 4W 7W F 5T
样例输出
#1:
D
#2:
#3:
N X 1W
#4:
1W Z 1W
提示
#include<iostream>
#include<string>
#include<cstring>
#include<string.h>
#include<algorithm>
#include<cmath>
#include<queue>
using namespace std;
queue<string>all_q;
queue<string>q[5];
queue<string>chu[5];
string pai;
int found;
int main()
{
while(!all_q.empty()) all_q.pop();
for(int i=1;i<=4;i++)
{
while(!q[i].empty())
q[i].pop();
while(!chu[i].empty())
chu[i].pop();
}
int a,b;
cin>>a>>b;
a=a+b;
int chu_pai=a%4;
if(chu_pai==0)
chu_pai=4;
int huan=-1;
if(chu_pai==1)
huan=(a-1)*2;
else if(chu_pai==4)
huan=34+(a-1)*2;
else if(chu_pai==3)
huan=68+(a-1)*2;
else
huan=102+(a-1)*2;
for(int i=1;i<=136;i++)
{
cin>>pai;
all_q.push(pai);
}
//从2a-1开始摸牌
for(int i=1;i<=huan;i++)
{
pai=all_q.front();
all_q.pop();
all_q.push(pai);
}
//3论
int z=1;
for(int i=1;i<=3;i++)
{
//从chu_pai开始,每个人摸4张
int lun=4;
while(lun--)
{
for(int j=0;j<=3;j++)
{
pai=all_q.front();
all_q.pop();
q[z].push(pai);
}
z--;
if(z==0)
z=4;
}
}
//打牌
z=1;
int is_peng=0;
while(true)
{
//摸牌
if(!is_peng)
{
if(!all_q.empty())
{
pai=all_q.front();
all_q.pop();
q[z].push(pai);
}
else
break;
}
//出牌
is_peng=0;
if(q[z].empty())
break;
pai=q[z].front();
//cout<<z<<" "<<"chu_pai "<<pai<<endl;
q[z].pop();
chu[z].push(pai);
found=z;
for(int i=1;i<=3;i++)
{
found=found+1;
if(found==5)
found=1;
//cout<<"found "<<found<<endl;;
int len=q[found].size();
int num=0;
for(int j=0;j<len;j++)
{
string his_card=q[found].front();
q[found].pop();
if(his_card==pai)
num++;
q[found].push(his_card);
}
/*if(found==4)
{
cout<<endl;
cout<<"pai "<<pai<<endl;
cout<<num<<endl;
}*/
if(num>=2)
{
is_peng=1;
for(int j=0;j<len;j++)
{
string his_card=q[found].front();
q[found].pop();
//碰掉的牌出掉
if(his_card!=pai)
{
q[found].push(his_card);
}
}
z=found;
break;
}
}
if(!is_peng)
{
z--;
if(z==0)
z=4;
}
}
for(int i=1;i<=4;i++)
{
cout<<"#"<<i<<":"<<endl;
int num=0;
if(chu[i].empty())
{
cout<<endl;
continue;
}
while(!chu[i].empty())
{
pai=chu[i].front();
chu[i].pop();
cout<<pai;
num++;
if(chu[i].empty()||num==10)
{
num=0;
cout<<endl;
}
else{
cout<<" ";
}
}
}
return 0;
}
C# Windows Api的一些方法 封装 以及 常用参数
Java基础—异常(1)
Java基础——异常(2)
vb6 wininet
vb6转16进制
Java 中与(&)短路与(&&)以及 或(|)短路或(||)的关系
关于面向对象的简单总结
javaScript的基本规范
关于TCP传输的三次握手四次挥手策略