2015 多校联赛 ——HDU5319(模拟)
Painter
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 895 Accepted Submission(s): 408
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.
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.
4
RR.B
.RG.
.BRR
B..R
4
RRBB
RGGB
BGGR
BBRR
6
按照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(模拟)的更多相关文章
- 2015 多校联赛 ——HDU5402(模拟)
For each test case, in the first line, you should print the maximum sum. In the next line you should ...
- 2015 多校联赛 ——HDU5373(模拟)
Problem Description In this problem, we should solve an interesting game. At first, we have an integ ...
- 2015 多校联赛 ——HDU5334(构造)
Virtual Participation Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Ot ...
- 2015 多校联赛 ——HDU5302(构造)
Connect the Graph Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others ...
- 2015 多校联赛 ——HDU5294(最短路,最小切割)
Tricks Device Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) To ...
- 2015 多校联赛 ——HDU5325(DFS)
Crazy Bobo Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 131072/65536 K (Java/Others) Tota ...
- 2015 多校联赛 ——HDU5316(线段树)
Fantasy magicians usually gain their ability through one of three usual methods: possessing it as an ...
- 2015 多校联赛 ——HDU5323(搜索)
Solve this interesting problem Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K ...
- 2015 多校联赛 ——HDU5301(技巧)
Your current task is to make a ground plan for a residential building located in HZXJHS. So you must ...
随机推荐
- 201621123031 《Java程序设计》第10周学习总结
作业10-异常 1.本周学习总结 1.1 以你喜欢的方式(思维导图或其他)归纳总结异常相关内容. 1.捕捉异常 Java中的异常捕获结构由try.catch和finally三个部分组成.其中try语句 ...
- 第一部分 linux系统命令
一.linux系统命令 pwd 当前目录位置 / 根目录 cd (change direcory) cd ..返回上一层目录 ls 显示当前目录下文件 ls -l 显示目录下详细文件信息 ls -lh ...
- nyoj 数的长度
描述 N!阶乘是一个非常大的数,大家都知道计算公式是N!=N*(N-1)······*2*1.现在你的任务是计算出N!的位数有多少(十进制)? 输入 首行输入n,表示有多少组测试数据(n<1 ...
- JAVA_SE基础——72.自定义线程
进程 : 正在执行的程序称作为一个进程. 进程负责了内存空间的划分. 问题: windows号称是多任务的操作系统,那么windows是同时运行多个应用程序吗?从宏观的角度: windows确 ...
- 美团点餐—listview内部按钮点击事件
PS:长时间不写博客了,今天来写一下美团的这个点餐界面,今天先写一个加号减号的接口调用,下一篇是整体,有点菜,评价,商家,还有左边的listview和右边的展示项.进入这篇正题,像listview,G ...
- Spark学习笔记之RDD中的Transformation和Action函数
总算可以开始写第一篇技术博客了,就从学习Spark开始吧.之前阅读了很多关于Spark的文章,对Spark的工作机制及编程模型有了一定了解,下面把Spark中对RDD的常用操作函数做一下总结,以pys ...
- C#微信公众号——消息处理
当普通微信用户向公众账号发消息时,微信服务器将POST消息的XML数据包到开发者填写的URL. 一.接收POST请求,处理XML信息 public void ProcessRequest(HttpC ...
- windbg分析Kernel32.dll导出表
写在前面的话: 继续上篇,在获得了Kernel32.dll基址的基础上,分析它的导出表结构: 对PE结构不太熟悉的同学,可以参考看雪论坛里的一篇帖子:https://bbs.pediy.com/thr ...
- 查看eclipse ADT SDK JDK版本号
一.查看eclipsea版本号: 启动eclipse,Help > About Eclipse SDK,在eclipse SDK对话框下面就有Eclipse SDK Version:4.2.0这 ...
- JAVAFX-5 开发应用
fx 属性与布局 属性与布局是一个具备gui开发能力的开发者,快速进入开发必备的知识储备,下面简单说一说常用的属性,与布局 颜色 颜色 在 javafx.scene.paint.Color 类中提供了 ...