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

输入
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[];
queue<string>chu[];
string pai;
int found;
int main()
{
while(!all_q.empty()) all_q.pop();
for(int i=;i<=;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%;
if(chu_pai==)
chu_pai=;
int huan=-;
if(chu_pai==)
huan=(a-)*;
else if(chu_pai==)
huan=+(a-)*;
else if(chu_pai==)
huan=+(a-)*;
else
huan=+(a-)*; for(int i=;i<=;i++)
{
cin>>pai;
all_q.push(pai);
}
//从2a-1开始摸牌
for(int i=;i<=huan;i++)
{
pai=all_q.front();
all_q.pop();
all_q.push(pai);
} //3论
int z=;
for(int i=;i<=;i++)
{
//从chu_pai开始,每个人摸4张
int lun=;
while(lun--)
{
for(int j=;j<=;j++)
{
pai=all_q.front();
all_q.pop();
q[z].push(pai);
}
z--;
if(z==)
z=;
}
}
//打牌
z=;
int is_peng=;
while(true)
{
//摸牌
if(!is_peng)
{
if(!all_q.empty())
{
pai=all_q.front();
all_q.pop();
q[z].push(pai);
}
else
break;
} //出牌
is_peng=;
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=;i<=;i++)
{
found=found+;
if(found==)
found=;
//cout<<"found "<<found<<endl;; int len=q[found].size();
int num=;
for(int j=;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>=)
{
is_peng=;
for(int j=;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==)
z=;
}
}
for(int i=;i<=;i++)
{
cout<<"#"<<i<<":"<<endl;
int num=;
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==)
{
num=;
cout<<endl;
}
else{
cout<<" ";
}
}
}
return ;
}
浙江财经大学第十五届大学生程序设计竞赛------B 烦恼先生打麻将的更多相关文章
- 校第十六届大学生程序设计竞赛暨2016省赛集训队选拔赛(Problem E)
Problem E Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total ...
- 黑龙江省第七届大学生程序设计竞赛-Mysterious Organization
描述 GFW had intercepted billions of illegal links successfully. It has much more effect. Today, GFW i ...
- 黑龙江省第七届大学生程序设计竞赛-Heap
描述 A heap is a full binary tree; for each node, its key is greater than its two sub-node’s key. Two ...
- “纽劢科技杯”第十六届同济大学程序设计竞赛暨上海邀请赛同步赛 J-张老师的游戏
传送门 题目描述 在空闲时间,张老师习惯性地和菜哭武玩起了取石子游戏,这次的游戏规则有些不同,在他们面前有n堆石子,其中,第i堆石子的个数为a[i],现在制定规则如下: 从张老师开始, ...
- 《内蒙古自治区第十三届大学生程序设计竞赛试题_H 公孙玉龙》
这个题有点小坑,最坑的地方就是 输入的b 变量 有可能 是 负数 ! 负数 ! 负数! 对 ,你没有看错,就是负数,坑死我了, 一直都是 content.charAt(0) 判断 ...
- ZOJ 4100 浙江省第16届大学生程序设计竞赛 A题 Vertices in the Pocket 线段树+并查集
正赛的时候完全没看这个题,事后winterzz告诉我他想出来的解法. 首先题意是给出n个点,m次操作. 操作有一种是连接两个点,另一种是求此时再为这个图连k条边,最少和最多能有几个联通块. 最少的求法 ...
- River Crossing---河南省第六届大学生程序设计竞赛
题目描述 Afandi is herding N sheep across the expanses of grassland when he finds himself blocked by a ...
- ZOJ 4103 浙江省第16届大学生程序设计竞赛 D题 Traveler 构造
这个题,正赛的时候也没有过,不过其实已经有了正确的解法,可惜时间不多了,就没有去尝试. 题意是有n个点,i点能通向i-1,然后i和i*2.i*2+1互通. 请你构造一种路径从1能走完所有点,并且不重复 ...
- Contest - 中南大学第六届大学生程序设计竞赛(Semilive)
题1:1160十进制-十六进制 注意他给的数据范围 2^31,int是 2^31-1 #include<iostream> using namespace std; int main() ...
随机推荐
- Python——dict(自定义类作key)
Python的dict要求key为不可变数据类型,通常采用str或int,但在某些应用场景下,需要采用自定义类型对象作key, 此时的自定义类需要实现两个特殊方法:__hash__.__eq__,用于 ...
- PHP用户登录解析
Web上的用户登录功能应该是最基本的功能了,可是在我看过一些站点的用户登录功能后,我觉得很有必要写一篇文章教大家怎么来做用户登录功能.下面 的文章告诉大家这个功能可能并没有你所想像的那么简单,这是一个 ...
- 直面Java 第002期
. Java和C++同为面向对象语言,Java和C++主要区别有哪些?双方个有哪些优缺点? 解: C++ 被设计成主要用在系统性应用程序设计上的语言,对C语言进行了扩展.对于C语言这个为运行效率设计的 ...
- js判断输入的字符是否是汉字
<script type="text/javascript"> var c=prompt("请输入一个字符"); var isNumber = c& ...
- SolrCore Initialization Failures - Max direct memory is likely too low
org.apache.solr.common.SolrException:org.apache.solr.common.SolrException: The max direct memory is ...
- hive array、map、struct使用
hive提供了复合数据类型:Structs: structs内部的数据可以通过DOT(.)来存取,例如,表中一列c的类型为STRUCT{a INT; b INT},我们可以通过c.a来访问域aMaps ...
- BizDevOps — the true value proposition of workflow engines
转自:https://blog.bernd-ruecker.com/bizdevops-the-true-value-proposition-of-workflow-engines-f342509ba ...
- 几个OOD概念
Composition vs. Aggregation Composition和Aggregation都是”包含”的关系 (part of, made up of) ,不同的是生命周期.对于Compo ...
- Day36 数据库的操作
视图操作: 1.左连接查询 select * from person left join dept on person.dept_id = dept.did 2. 右连接 3. 内连接 inner ...
- 推荐一篇文章 《为什么C语言不会过时?》
<为什么C语言不会过时?> 文章地址 : https://mp.weixin.qq.com/s?__biz=MzAxOTc0NzExNg==&mid=2665515153&a ...