2015 多校联赛 ——HDU5319(模拟)

时间:2023-01-16 11:56:38

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. js测试题

    (function(){ return typeof arguments;})();"object" var f = function g(){ return 23; };type ...

  2. 混合使用C和C&plus;&plus;

    C++作为C语言的扩展集,几乎所有的C程序都可以在C++中编译和运行,但是要注意C程序中可能使用了C++中的关键字作为变量,比如在C中:int class = 0; 但这在C++中不行.出于方便性,我 ...

  3. HW4&period;37

    import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner i ...

  4. PS 色彩的色相谱

    7- 色彩的色相谱 在这个环中,位于180度夹角的两种颜色(也就是圆的某条直径两端的颜色),称为反转色,又称为互补色.互补的两种颜色之间是此消彼长的关系,小框往蓝色移动的同时就会远离黄色, 黄色=白色 ...

  5. hdu1848 Fibonacci again and again&lpar;SG游戏功能&rpar;

    现在的变化是看不清楚SG功能什么寻求方法 临时模板标题是首当 性能mex1它正在寻求g(x) 然后XOR #include<cstdio> #include<iostream> ...

  6. webpack 3&period;X学习之JS压缩与打包HTML文件

    js压缩 webpack自带一个插件uglifyjs-webpack-plugin来压缩js,所以不需要再次安装,当一切都准备妥当,引入uglifyjs-webpack-plugin模块: const ...

  7. XOR算法的原理和实现

    XOR算法的原理和实现 XOR算法这种方法的原理 当一个数A和另一个数B进行异或运算会生成另一个数C,如果再将C和B进行异或运算则C又会还原为A. 相对于其他的简易加密算法,XOR算法的优点如下. ( ...

  8. MySQL父子节点查询

    MySQL父子结点递归查询 表结构: CREATE TABLE `agency` ( `id` ) NOT NULL COMMENT '编号', `name` ) NOT NULL COMMENT ' ...

  9. HttpClient4&period;5简单使用

    一.HttpClient简介 HttpClient是一个客户端的HTTP通信实现库,它不是一个浏览器.关于HTTP协议,可以搜索相关的资料.它设计的目的是发送与接收HTTP报文.它不会执行嵌入在页面中 ...

  10. Ubuntu16&period;04 - 安装RabbitVCS,linux下的TortoiseSVN!!!

    RabbitVCS 官网:http://rabbitvcs.org/ 1,添加PPA源.在shell里面执行下面命令: sudo add-apt-repository ppa:rabbitvcs/pp ...