Painter

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 895    Accepted Submission(s): 408

Problem Description
Mr. Hdu is an painter, as we all know, painters need ideas to innovate , one day, he got stuck in rut and the ideas dry up, he took out a drawing board and began to draw casually. Imagine the board is a rectangle, consists of several square grids. He drew diagonally,
so there are two kinds of draws, one is like ‘\’ , the other is like ‘/’. In each draw he choose arbitrary number of grids to draw. He always drew the first kind in red color, and drew the other kind in blue color, when a grid is drew by both red and blue,
it becomes green. A grid will never be drew by the same color more than one time. Now give you the ultimate state of the board, can you calculate the minimum time of draws to reach this state.
 
Input
The first line is an integer T describe the number of test cases.
Each test case begins with an integer number n describe the number of rows of the drawing board.
Then n lines of string consist of ‘R’ ‘B’ ‘G’ and ‘.’ of the same length. ‘.’ means the grid has not been drawn.
1<=n<=50
The number of column of the rectangle is also less than 50.
Output
Output an integer as described in the problem description.
 
Output
Output an integer as described in the problem description.
 
Sample Input
2
4
RR.B
.RG.
.BRR
B..R
4
RRBB
RGGB
BGGR
BBRR
 
Sample Output
3
6
 
Author
ZSTU
 
Source

按照45度刷墙,红色的从左上 ->右下,蓝色从右上->左下,一种颜色对一个点只能刷一次,红 + 蓝 ->绿

模拟即过。

(论英语的重要性!!   看半天才懂什么意思)

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <stdlib.h>
using namespace std; char Map[60][60]; int main()
{
int n,T;
// freopen("4.txt","r",stdin);
scanf("%d",&T);
while(T--)
{
scanf("%d",&n);
for(int i = 0; i < n; i++)
scanf("%s",Map[i]);
int i,j;
int tot= 0;
int len = strlen(Map[0]);
for(i = 0; i < n; i++)
for(j = 0; j < len; j++)
{
if(Map[i][j] == 'R' || Map[i][j] == 'r')
{
tot++;
Map[i][j] = '.';
for(int k = 1; k + i < n && j + k < len; k++)
{
if(Map[i+k][j+k] == 'R' || Map[i+k][j+k] == 'r')
Map[i+k][j+k] = '.'; else if(Map[i+k][j+k] == 'G')
Map[i+k][j+k] = 'b'; else
break;
}
}
if(Map[i][j] == 'B' || Map[i][j] == 'b')
{
tot++;
Map[i][j] = '.';
for(int k = 1; k + i < n && j - k >= 0; k++)
{
if(Map[i+k][j-k] == 'B' || Map[i+k][j-k] == 'b')
Map[i+k][j-k] = '.'; else if(Map[i+k][j-k] == 'G')
Map[i+k][j-k] = 'r'; else
break;
}
}
if(Map[i][j] == 'G')
{
tot+=2;
Map[i][j] = '.';
for(int k = 1; k + i < n && j - k >= 0; k++)
{
if(Map[i+k][j-k] == 'G')
Map[i+k][j-k] = 'r';
else if(Map[i+k][j-k] == 'B' || Map[i+k][j-k] == 'b')
Map[i+k][j-k] = '.';
else
break;
}
for(int k = 1; k + i < n && j + k < len ; k++)
{
if(Map[i+k][j+k] == 'G')
Map[i+k][j+k] = 'b';
else if(Map[i+k][j+k] == 'R' || Map[i+k][j+k] == 'r')
Map[i+k][j+k] = '.';
else
break;
}
}
}
printf("%d\n",tot);
}
return 0;
}

  

2015 多校联赛 ——HDU5319(模拟)的更多相关文章

  1. 2015 多校联赛 ——HDU5402(模拟)

    For each test case, in the first line, you should print the maximum sum. In the next line you should ...

  2. 2015 多校联赛 ——HDU5373(模拟)

    Problem Description In this problem, we should solve an interesting game. At first, we have an integ ...

  3. 2015 多校联赛 ——HDU5334(构造)

    Virtual Participation Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Ot ...

  4. 2015 多校联赛 ——HDU5302(构造)

    Connect the Graph Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others ...

  5. 2015 多校联赛 ——HDU5294(最短路,最小切割)

    Tricks Device Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) To ...

  6. 2015 多校联赛 ——HDU5325(DFS)

    Crazy Bobo Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 131072/65536 K (Java/Others) Tota ...

  7. 2015 多校联赛 ——HDU5316(线段树)

    Fantasy magicians usually gain their ability through one of three usual methods: possessing it as an ...

  8. 2015 多校联赛 ——HDU5323(搜索)

    Solve this interesting problem Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K ...

  9. 2015 多校联赛 ——HDU5301(技巧)

    Your current task is to make a ground plan for a residential building located in HZXJHS. So you must ...

随机推荐

  1. 在深度linux下安装pip3与jupyter

    前言 以下安装说明基于已经正确安装python3 文件下载 https://pypi.python.org/pypi/pip 下载pip-9.0.1.tar.gz (md5, pgp)文件 安装准备工 ...

  2. zookeeper 入门系列-理论基础 – zab 协议

    上一章讨论了paxos算法,把paxos推到一个很高的位置.但是,paxos有没有什么问题呢?实际上,paxos还是有其自身的缺点的: 1. 活锁问题.在base-paxos算法中,不存在leader ...

  3. 深度学习之 mnist 手写数字识别

    深度学习之 mnist 手写数字识别 开始学习深度学习,先来一个手写数字的程序 import numpy as np import os import codecs import torch from ...

  4. GIT入门笔记(20)- 使用eclipse 基于 git 开发过程梳理

    一.创建本地分支 1.下载/更新 本地 主干 如果本地还没有 本地主干,下载:git clone 如果本地已有了 本地主干,更新:git pull 工程右键菜单:team -> pull 2.基 ...

  5. NHibernate从入门到精通系列(2)——NHibernate环境与结构体系

    内容摘要 NHibernate的开发环境 NHibernate的结构体系 NHibernate的配置 一.NHibernate的开发环境 NHibernate的英文官方网站为:http://nhfor ...

  6. 百度地图api的用法

    功能: 1.点击"江干区",地图自动定位到该区域,并且该区域出现overlay(红色) 2.点击"派出所"."社区"级别时,地图也自动定位同 ...

  7. pythonllk

    字符编码 数据类型 函数  装饰器  内置函数 迭代器 生成器 异常 反射 模块 类 对象 类的进阶 socket 进程线程 httphtmlcssJavaScriptjquery MysqlMysq ...

  8. pandas笔记

    axis = 1表示按列的方向遍历 axis = 0表示按行的方向遍历 Usually axis=0 is said to be "column-wise" (and axis=1 ...

  9. hadoop fs:du统计hdfs文件(目录下文件)大小的用法

    hadoop fs 更多用法,请参考官网:http://hadoop.apache.org/docs/r1.0.4/cn/hdfs_shell.html 以下是我的使用统计文件时使用的记录: [t@d ...

  10. Mysql:查用的基本操作

    查看MySQL提供什么存储引擎: mysql> show engines; 查看MySQL当前默认的存储引擎: mysql> show variables like '%storage_e ...