初看题目时就发了个错误,我因为没有耐心看题而不了解题目本身的意思,找不到做题的突破口,即使看了一些题解,还是没有想到方法。

后来在去问安叔,安叔一语道破天机,问我有没有搞清题目的意思,我才恍然大悟,做题当然要先搞懂题目意思,不然做什么题呢!以后一定要再三注意!而且要把每一个细节都注意到!

POJ - 2339 Rock, Scissors, Paper

Time Limit: 5000MS

Memory Limit: 65536KB

64bit IO Format: %I64d & %I64u

Description

Bart's sister Lisa has created a new civilization on a two-dimensional grid. At the outset each grid location may be occupied by one of three life forms: Rocks, Scissors, or Papers. Each day, differing life forms occupying horizontally or vertically adjacent grid locations wage war. In each war, Rocks always defeat Scissors, Scissors always defeat Papers, and Papers always defeat Rocks. At the end of the day, the victor expands its territory to include the loser's grid position. The loser vacates the position. 
Your job is to determine the territory occupied by each life form after n days.

Input

The first line of input contains t, the number of test cases. Each test case begins with three integers not greater than 100: r and c, the number of rows and columns in the grid, and n. The grid is represented by the r lines that follow, each with c characters. Each character in the grid is R, S, or P, indicating that it is occupied by Rocks, Scissors, or Papers respectively.

Output

For each test case, print the grid as it appears at the end of the nth day. Leave an empty line between the output for successive test cases.

Sample Input

2

3 3 1

RRR

RSR

RRR

3 4 2

RSPR

SPRS

PRSP

Sample Output

RRR

RRR

RRR

RRRS

RRSP

RSPR

Source

Waterloo local 2003.01.25

 #include<stdio.h>
#include<string.h>
#include<math.h>
#include<stdlib.h>
char toda[][];
char tomo[][];
int main()
{
int t = , r = , c = , n = , i = , j = ;
scanf("%d", &t);
while(t--) {
scanf("%d%d%d", &r, &c, &n);
for(i = ; i < r; i++) {
scanf("%s", toda[i]);
}
for(i = ; i < r; i++) {
for(j = ; j < c; j++) {
tomo[i][j] = toda[i][j];
}
}
while(n--) {
for(i = ; i < r; i++) {
for(j = ; j < c; j++) {
if(toda[i][j] == 'R') {
if(j+ < c && toda[i][j+] == 'S')
tomo[i][j+] = 'R';
if(i- >= && toda[i-][j] == 'S')
tomo[i-][j] = 'R';
if(j- >= && toda[i][j-] == 'S')
tomo[i][j-] = 'R';
if(i+ < r && toda[i+][j] == 'S')
tomo[i+][j] = 'R';
}
else if(toda[i][j] == 'S') {
if(j+ < c && toda[i][j+] == 'P')
tomo[i][j+] = 'S';
if(i- >= && toda[i-][j] == 'P')
tomo[i-][j] = 'S';
if(j- >= && toda[i][j-] == 'P')
tomo[i][j-] = 'S';
if(i+ < r && toda[i+][j] == 'P')
tomo[i+][j] = 'S';
}
else {
if(j+ < c && toda[i][j+] == 'R')
tomo[i][j+] = 'P';
if(i- >= && toda[i-][j] == 'R')
tomo[i-][j] = 'P';
if(j- >= && toda[i][j-] == 'R')
tomo[i][j-] = 'P';
if(i+ < r && toda[i+][j] == 'R')
tomo[i+][j] = 'P';
}
}
}
for(i = ; i < r; i++) {
for(j = ; j < c; j++) {
toda[i][j] = tomo[i][j];
}
}
}
for(i = ; i < r; i++) {
for(j = ; j < c; j++) {
printf("%c", toda[i][j]);
}
printf("\n");
}
if(n) printf("\n");
}
return ;
}

POJ - 2339 Rock, Scissors, Paper的更多相关文章

  1. POJ 2339

    #include <iostream> #include <algorithm> #define MAXN 205 using namespace std; char _m[M ...

  2. POJ 题目分类(转载)

    Log 2016-3-21 网上找的POJ分类,来源已经不清楚了.百度能百度到一大把.贴一份在博客上,鞭策自己刷题,不能偷懒!! 初期: 一.基本算法: (1)枚举. (poj1753,poj2965 ...

  3. (转)POJ题目分类

    初期:一.基本算法:     (1)枚举. (poj1753,poj2965)     (2)贪心(poj1328,poj2109,poj2586)     (3)递归和分治法.     (4)递推. ...

  4. poj分类

    初期: 一.基本算法:      (1)枚举. (poj1753,poj2965)      (2)贪心(poj1328,poj2109,poj2586)      (3)递归和分治法.      ( ...

  5. poj 题目分类(1)

    poj 题目分类 按照ac的代码长度分类(主要参考最短代码和自己写的代码) 短代码:0.01K--0.50K:中短代码:0.51K--1.00K:中等代码量:1.01K--2.00K:长代码:2.01 ...

  6. POJ题目分类(按初级\中级\高级等分类,有助于大家根据个人情况学习)

    本文来自:http://www.cppblog.com/snowshine09/archive/2011/08/02/152272.spx 多版本的POJ分类 流传最广的一种分类: 初期: 一.基本算 ...

  7. POJ题目分类(转)

    初期:一.基本算法:     (1)枚举. (poj1753,poj2965)     (2)贪心(poj1328,poj2109,poj2586)     (3)递归和分治法.     (4)递推. ...

  8. POJ题目细究

    acm之pku题目分类 对ACM有兴趣的同学们可以看看 DP:  1011   NTA                 简单题  1013   Great Equipment     简单题  102 ...

  9. POJ题目(转)

    http://www.cnblogs.com/kuangbin/archive/2011/07/29/2120667.html 初期:一.基本算法:     (1)枚举. (poj1753,poj29 ...

随机推荐

  1. Redis常用命令(一)

    Redis::__construct描述:创建一个Redis客户端范例:$redis = new Redis(); connect, open描述:实例连接到一个Redis.参数:host: stri ...

  2. 原生javascript封装ajax和jsonp

    在我们请求数据时,完成页面跨域,利用原生JS封装的ajax和jsonp: <!DOCTYPE html> <html lang="en"> <head ...

  3. view保存为图片

    一.概述 简书.微博.便签等都有将文章保存为图片的功能.笔者臆测,此功能的实现原理如下. 二.实现 2.1将View保存成Bitmap对象 方法1(亲测有效) private Bitmap makin ...

  4. android-数据存储之手机内部file存储

    一.基础概要 1.说明: 1>应用程序运行需要一些较大的数据或者图片可保存在手机内部 2>文件类型:任意 3>路径:/data/data/packageName/files/ 4&g ...

  5. Hadoop.2.x_源码编译

    一.基本环境搭建 1. 准备 hadoop-2.5.0-src.tar.gz apache-maven-3.0.5-bin.tar.gz jdk-7u67-linux-x64.tar.gz proto ...

  6. intellij idea 插件 ideaVim

    像Eclipse一样,idea这个公认最好的javaIDE也有Vim插件. 安装方法 File>Settings>Plugins>Install JetBrains plugin.. ...

  7. HTML静态网页 图片热点、框架、表单

    图片热点: 规划出图片上的一个区域,可以做出超链接,直接点击图片区域就可以完成跳转的效果. 示例: 网页划区: 在一个网页里,规划出一个区域用来展示另一个网页的内容. 示例: 框架: 1.frames ...

  8. IOS第14天(2, Modal控制)

    ******控制器modal - (void)btnClick { // 创建控制器对象 HMJumpViewController *jump = [[HMJumpViewController all ...

  9. 论url

    http://www.cnblogs.com/yexiaochai/p/3650379.css文件中 background: (../images/logo.png); http://www.cnbl ...

  10. 【iCore3 双核心板】例程三:EXTI中断输入实验——读取ARM按键状态

    实验指导书及代码包下载: http://pan.baidu.com/s/1o6xToN4 iCore3 购买链接: https://item.taobao.com/item.htm?id=524229 ...