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. 201621123040《Java程序设计》第4周学习总结

    1.本周学习总结 1.1写出你认为本周学习中比较重要的知识点关键词 关键词:继承 多态性 基本语法 重新定义Override 1.2尝试使用思维导图将这些关键词组织起来.注:思维导图一般不需要出现过多 ...

  2. Raid5两块硬盘掉线可以恢复数据吗_raid数据恢复案例分享

    本案例中发生故障的存储类型是HP P2000,虚拟化平台为vmware exsi,共有10块硬盘组成raid5(硬盘容量为1t,其中6号盘是热备盘),由于某些故障导致阵列中两块硬盘亮黄灯掉线,硬盘无法 ...

  3. 一个页面多个HTTP请求 页面卡顿!

    用promise解决 前两天面试的时候 一个面试官问到这样一个问题 这里先说出解决的路径 这几天会更新具体的做法 或者直接参考廖雪峰大神 地址如下: https://www.liaoxuefeng.c ...

  4. Echarts 折线图y轴标签值太长时显示不全的解决办法

    问题 分析 解决办法 问题 先看一下正常的情况 再看一下显示不全的情况 所有的数据都是从后台取的,也就是说动态变化的,一开始的时候数据量不大不会出现问题,后面y轴的值越来越大的时候就出现了这个显示不全 ...

  5. 从PRISM开始学WPF(九)交互(完结)

    0x07交互 Notification xaml: <Window x:Class="UsingPopupWindowAction.Views.MainWindow" xml ...

  6. gogs详细配置

    sudo apt-get update sudo apt-get upgrade sudo adduser git //创建用户  密码 ******* su git//切换到git用户 cd ~   ...

  7. 基于python的统计公报关键数据爬取

    # -*- coding: utf-8 -*- """ Created on Wed Nov 8 14:23:14 2017 @author: 123 "&qu ...

  8. Spring整合MyBaytis

    1.准备jar包 A.第一种方式:配置SqlSessionFactoryBean+配置SqlSessionTemplate a.项目结构 b.applicationContext.xml  带详细注释 ...

  9. python判断素数的方法

    #运用python的数学函数 import math def isPrime(n): if n <= 1: return False for i in range(2, int(math.sqr ...

  10. Python系列之 - 锁(GIL,Lock,Rlock,Event,信号量)

    python 的解释器,有很多种,但市场占有率99.9%的都是基于c语言编写的CPython.  在这个解释器里规定了GIL. In CPython, the global interpreter l ...