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

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

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. Spring 整合 Redis(二)

    pom构建: <modelVersion>4.0.0</modelVersion> <groupId>com.x.redis</groupId> < ...

  2. 模拟淘宝使用cookie记录登录名,

    <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding= ...

  3. HTML基础--JS简介、基本语法、类型转换、变量、运算符、分支语句、循环语句、数组、函数、函数调用.avi

    JS简介 1.JavaScript是个什么东西? 它是个脚本语言,需要有宿主文件,它的宿主文件是HTML文件. 2.它与Java什么关系? 没有什么直接的联系,Java是Sun公司(已被Oracle收 ...

  4. 第三章 Odoo基本设置

    登录 正常访问http://localhost:8069后,登录的界面如下: 这是Odoo默认的认证方式,也是我们最常见最熟悉的认证方式,7.0以前,数据库中的密码都是以明文方式存储,可以很轻松地在r ...

  5. HDU2563 递推

    统计问题 Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submis ...

  6. Hibernate查询 Query Language

    1,Native SQL ->HQL->EJBQL->QBC(Query By Cretira)->QBE(Query By Example) 此排列是根据可实现功能大小排序.

  7. 云计算仿真软件Cloudsim介绍以及类的功能介绍

    一·云计算的介绍 云计算仿真软件,称为CloudSim.它是在离散事件模拟包SimJava上开发的函数库,可在Windows和Linux系统上跨平台运行,CloudSim继承了GridSim的编程模型 ...

  8. 2016HUAS暑假集训训练题 B - Catch That Cow

    B - Catch That Cow Description Farmer John has been informed of the location of a fugitive cow and w ...

  9. log4j日志输出级别高低

    Log4j是Apache的开源项目一个功能强大的日志组件,提供方便的日志记录.日志记录器(Logger)是日志处理的核心组件Log4j建议只使用四个级别,优先级从高到低分别是FATAL, ERROR. ...

  10. 关于web-dev-server 记录

    package.json "scripts": { "init": "webpack --progress --config webpack.dev. ...