POJ 2339
#include <iostream>
#include <algorithm>
#define MAXN 205
using namespace std; char _m[MAXN][MAXN]; char tem[MAXN][MAXN]; bool cmp(char a,char b); int r; int c; void fun(); bool cmp(char a,char b); int main()
{
//freopen("acm.acm","r",stdin);
int i;
int j;
int test;
int a = ;
cin>>test; int time;
while(test --)
{
if(a != )
cout<<endl;
cin>>r>>c>>time;
a = ;
for(i = ; i < r; ++ i)
{
for(j = ; j < c; ++ j)
{
cin>>_m[i][j];
}
}
for(i = ; i < r; ++ i)
{
for(j = ; j < c; ++ j)
{
tem[i][j] = _m[i][j];
}
}
for(i = ; i < time; ++ i)
{
fun();
}
for(i = ; i < r; ++ i)
{
for(j = ; j < c; ++ j)
{
cout<<_m[i][j];
}
cout<<endl;
} } } void fun()
{
int i;
int j;
for(i = ; i < r; ++ i)
{
for(j = ; j < c; ++ j)
{
if(i + < r)
{
if(cmp(_m[i+][j],_m[i][j]))
{
tem[i][j] = _m[i+][j];
continue;
}
}
if(j + < c)
{
if(cmp(_m[i][j+],_m[i][j]))
{
tem[i][j] = _m[i][j+];
continue;
}
}
if(i - >= )
{
if(cmp(_m[i-][j],_m[i][j]) )
{
tem[i][j] = _m[i-][j];
continue;
}
}
if(j - >= )
{
if(cmp(_m[i][j-],_m[i][j]))
{
tem[i][j] = _m[i][j-];
continue;
}
}
}
} for(i = ; i < r; ++ i)
{
for(j = ; j < c; ++ j)
{
_m[i][j] = tem[i][j];
}
} } bool cmp(char a,char b)
{
if(a == 'R' && b == 'S')
{
return true;
}
else if(a == 'R' && b == 'P')
{
return false;
}
else if(a == 'P' && b == 'R')
{
return true;
}
else if(a == 'P' && b == 'S')
{
return false;
}
else if(a == 'S' && b == 'P')
{
return true;
}
else if(a == 'S' && b == 'R')
{
return false;
}
return false;
}
POJ 2339的更多相关文章
- POJ - 2339 Rock, Scissors, Paper
初看题目时就发了个错误,我因为没有耐心看题而不了解题目本身的意思,找不到做题的突破口,即使看了一些题解,还是没有想到方法. 后来在去问安叔,安叔一语道破天机,问我有没有搞清题目的意思,我才恍然大悟,做 ...
- POJ 题目分类(转载)
Log 2016-3-21 网上找的POJ分类,来源已经不清楚了.百度能百度到一大把.贴一份在博客上,鞭策自己刷题,不能偷懒!! 初期: 一.基本算法: (1)枚举. (poj1753,poj2965 ...
- (转)POJ题目分类
初期:一.基本算法: (1)枚举. (poj1753,poj2965) (2)贪心(poj1328,poj2109,poj2586) (3)递归和分治法. (4)递推. ...
- poj分类
初期: 一.基本算法: (1)枚举. (poj1753,poj2965) (2)贪心(poj1328,poj2109,poj2586) (3)递归和分治法. ( ...
- poj 题目分类(1)
poj 题目分类 按照ac的代码长度分类(主要参考最短代码和自己写的代码) 短代码:0.01K--0.50K:中短代码:0.51K--1.00K:中等代码量:1.01K--2.00K:长代码:2.01 ...
- POJ题目分类(按初级\中级\高级等分类,有助于大家根据个人情况学习)
本文来自:http://www.cppblog.com/snowshine09/archive/2011/08/02/152272.spx 多版本的POJ分类 流传最广的一种分类: 初期: 一.基本算 ...
- POJ题目分类(转)
初期:一.基本算法: (1)枚举. (poj1753,poj2965) (2)贪心(poj1328,poj2109,poj2586) (3)递归和分治法. (4)递推. ...
- POJ题目细究
acm之pku题目分类 对ACM有兴趣的同学们可以看看 DP: 1011 NTA 简单题 1013 Great Equipment 简单题 102 ...
- POJ题目(转)
http://www.cnblogs.com/kuangbin/archive/2011/07/29/2120667.html 初期:一.基本算法: (1)枚举. (poj1753,poj29 ...
随机推荐
- Devexpress VCL Build v2013 vol 14.1.5 发布
What's New in 14.1.5 (VCL Product Line) New Major Features in 14.1 What's New in VCL Products 14.1 ...
- 48 Fixing relationship Problems with Humor 用幽默解决人际关系问题
48 Fixing relationship Problems with Humor 用幽默解决人际关系问题 ①We've all heard that laughter is the best me ...
- json&pickle
用于序列化的两个模块 json,用于字符串 和 python数据类型间进行转换pickle,用于python特有的类型 和 python的数据类型间进行转换Json模块提供了四个功能:dumps.du ...
- 山东省第七届ACM竞赛 J题 Execution of Paladin (题意啊)
题意:鱼人是炉石里的一支强大种族,在探险者协会里,圣骑士有了一张新牌,叫亡者归来,效果是召唤本轮游戏中7个已死鱼人.如果死掉的不足7个,那么召唤的数量就会不足7. 鱼人有很多,下面的4个是: 寒光智者 ...
- 几个经典的数学库之一学习---VCGlib(1)
1. VCG Libary是Visulization and Computer Graphics Libary(可视化与计算机图形学库)的缩写,是一个开源的C++模板库,用于三角网格和四面体网格的控制 ...
- 从hbase到hive,以及sqoop转到mysql解析
https://blog.csdn.net/qq_33689414/article/details/80328665 hive关联hbase的配置文件 hive和hbase同步https://cwik ...
- node API assert
1.assert.throws(block, [error], [message]): assert.throws( function(){ throw new Error('wrong'); }, ...
- 转:ObjectInputStream类和ObjectInputStream类的使用
ObjectInputStream和ObjectInputStream类创建的对象被称为对象输入流和对象输出流. 创建文件输出流代码: FileOutputStream file_out = new ...
- EBS _ALL, _TL, _VL, _V,_F,_VL,_A,_AVN and what else
http://hi.baidu.com/einsteinalbert/item/54579250efc637abadc85705 _ALL, _TL, _VL, _V,_F,_VL,_A,_AVN a ...
- 笔记本U盘安装CentOS 7
1. 下载镜像,制作U盘安装盘,设置BIOS启动等内容网上有大量的文章,本文不再赘述. 2. 开机U盘启动后会看到这样的界面: 3. 笔记本安装CentOS最容易出问题的地方在于USB安装盘的选择,如 ...