问题 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

输出

#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 烦恼先生打麻将的更多相关文章

  1. 校第十六届大学生程序设计竞赛暨2016省赛集训队选拔赛(Problem E)

    Problem E Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total ...

  2. 黑龙江省第七届大学生程序设计竞赛-Mysterious Organization

    描述 GFW had intercepted billions of illegal links successfully. It has much more effect. Today, GFW i ...

  3. 黑龙江省第七届大学生程序设计竞赛-Heap

    描述 A heap is a full binary tree; for each node, its key is greater than its two sub-node’s key. Two ...

  4. “纽劢科技杯”第十六届同济大学程序设计竞赛暨上海邀请赛同步赛 J-张老师的游戏

    传送门 题目描述     在空闲时间,张老师习惯性地和菜哭武玩起了取石子游戏,这次的游戏规则有些不同,在他们面前有n堆石子,其中,第i堆石子的个数为a[i],现在制定规则如下:     从张老师开始, ...

  5. 《内蒙古自治区第十三届大学生程序设计竞赛试题_H 公孙玉龙》

    这个题有点小坑,最坑的地方就是  输入的b 变量  有可能 是  负数  !   负数 !  负数!    对 ,你没有看错,就是负数,坑死我了, 一直都是  content.charAt(0) 判断 ...

  6. ZOJ 4100 浙江省第16届大学生程序设计竞赛 A题 Vertices in the Pocket 线段树+并查集

    正赛的时候完全没看这个题,事后winterzz告诉我他想出来的解法. 首先题意是给出n个点,m次操作. 操作有一种是连接两个点,另一种是求此时再为这个图连k条边,最少和最多能有几个联通块. 最少的求法 ...

  7. River Crossing---河南省第六届大学生程序设计竞赛

    题目描述 Afandi is herding N sheep across the expanses of grassland  when he finds himself blocked by a ...

  8. ZOJ 4103 浙江省第16届大学生程序设计竞赛 D题 Traveler 构造

    这个题,正赛的时候也没有过,不过其实已经有了正确的解法,可惜时间不多了,就没有去尝试. 题意是有n个点,i点能通向i-1,然后i和i*2.i*2+1互通. 请你构造一种路径从1能走完所有点,并且不重复 ...

  9. Contest - 中南大学第六届大学生程序设计竞赛(Semilive)

    题1:1160十进制-十六进制 注意他给的数据范围 2^31,int是 2^31-1 #include<iostream> using namespace std; int main() ...

随机推荐

  1. java路径

    System.out.println(ResourceUtils.getURL("classpath:").getPath());

  2. (10)MySQL触发器(同时操作两张表)

    什么是触发器 触发器是与表有关的数据库对象,在满足定义条件时触发,并执行触发器中定义的语句集合.触发器的这种特性可以协助应用在数据库端确保数据的完整性. 举个例子,比如你现在有两个表[用户表]和[日志 ...

  3. 一道dp[不太好写]

    http://acm.csu.edu.cn:20080/csuoj/problemset/problem?pid=2281 Description An arithmetic progression ...

  4. 鸟哥的linux私房菜第4版--自学笔记

    -----------------------------------第一章 intel芯片架构 PS:升级电脑还得看看主板是不是适合CPU,主板适合CPU的类型是有限的PS: 现在已经没有北桥了,已 ...

  5. ORM 之常用重点 ******

    总体介绍orm>>点我 单表查询api汇总  如 distinc(),order_by()  id__gt=1  id__inrange=[ 1,3 ]  左右都包含     设置logg ...

  6. 使用kube_ping进行Keycloak群集设置 - DZone Cloud

    转自:https://www.jdon.com/51501 看看如何使用kube_ping和Keycloak实现自动发现? Keycloak是一个开源软件,提供身份管理和访问管理的单点登录.Keyco ...

  7. 随机重拍与抽样(random_shuffle,random_sample,random_sample_n)

    //版本一:使用内部的随机数生成器 template<class RandomAccessIterator> void random_shuffle( RandomAccessIterat ...

  8. java BIO/NIO

    一.BIO Blocking IO(即阻塞IO); 1.      特点: a)   Socket服务端在监听过程中每次accept到一个客户端的Socket连接,就要处理这个请求,而此时其他连接过来 ...

  9. web 前端安全问题

    转载自:https://segmentfault.com/a/1190000006672214?utm_source=weekly&utm_medium=email&utm_campa ...

  10. taro 消息机制

    Taro 提供了 Taro.Events 来实现消息机制,使用时需要实例化它 同时 Taro 还提供了一个全局消息中心 Taro.eventCenter 以供使用,它是 Taro.Events 的实例 ...