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. NodeJs实现自定义分享功能,获取微信授权+用户信息

    最近公司搞了个转盘抽奖的运营活动,入口放在了微信公众号里,好久没碰过微信了,刚拾起来瞬间感觉有点懵逼....似乎把之前的坑又都重新踩了一遍,虽然过程曲折,不过好在顺利完成了,而且印象也更加深刻了,抽时 ...

  2. MySQL 主从复制那些事(一)

    本部分主要以理论为主,具体的主从搭建环境,大家可以参考博客其他部分.下面我就给大家数说主从复制那些理论的东西.说的不一定都是正确的,有不同出入的地方,欢迎大家一起交流沟通,以下我把我自己整理出来的主从 ...

  3. angular2 学习笔记 ( 状态管理 state management )

    更新 : 2017-12-29  ng5 移除 zone.js https://zhuanlan.zhihu.com/p/29577461 zone 的用途就是拦截游览器事件, 比如 click, a ...

  4. Linux--慕课学习

    刚开始接触Linux,很有幸的在慕课网上看到了Peter老师的Linux入门课程,老师讲课真的式行云流水,深入浅出,循循善诱,层层递进. 老师分享的都是自己多年来总结的经验.看完之后也学到了很多东西. ...

  5. Mybatis自动生成Xml文件,针对字段类型为text等会默认产生XXXXWithBlobs的方法问题

    默认情况下产生的Mapper.xml里面存在: 需要修改generatorConfiguration.xml,里面的table加属性,如: <table domainObjectName=&qu ...

  6. Ecplise 配置本地 https 测试

    今天做项目,需要关联Office 365.为了实现Office365的用户邮件信息与项目的实时同步,需要建立webhook订阅. Office 365 API 连接  https://graph.mi ...

  7. nohup 与 & 的区别

    nohup -- invoke a utility immune to hangups : 运行命令忽略挂起信号 & 是指后台运行: nohup 的功能和& 之间的功能并不相同.其中, ...

  8. python/socket编程之粘包

    python/socket编程之粘包 粘包 只有TCP有粘包现象,UDP永远不会粘包. 首先需要掌握一个socket收发消息的原理 发送端可以是1k,1k的发送数据而接受端的应用程序可以2k,2k的提 ...

  9. 测试驱动开发实践5————testSave之修改文档分类

    [内容指引] 1.确定"修改文档分类"的微服务接口及所需的参数 2.设计测试用例及测试用例合并 3.为测试用例赋值并驱动开发 上一篇我们通过17个测试用例完成了"新增文档 ...

  10. 在删除一个指针之后,一定将该指针设置成空指针(即在delete *p之后一定要加上: p=NULL)

    在删除一个指针之后,一定将该指针设置成空指针(即在delete *p之后一定要加上: p=NULL)