hdu 5319 Painter(杭电多校赛第三场)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5319
Painter
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 826 Accepted Submission(s):
383
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.
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.
description.
6
#include <iostream>
#include <cstdio>
#include <cstring> using namespace std; int Map[][];
char ch[]; int main()
{
int t;
scanf("%d",&t);
while (t--)
{
int n,m;
scanf("%d",&n);
memset(Map,,sizeof(Map));
for (int i=;i<n;i++)
{
scanf("%s",ch);
m=strlen(ch);
for (int j=;j<m;j++)
{
if (ch[j]=='.')
Map[i][j]=;
else if (ch[j]=='R')
Map[i][j]=;
else if (ch[j]=='B')
Map[i][j]=-;
else
Map[i][j]=;
}
}
int sum=;
for (int i=;i<n;i++)
{
for (int j=;j<m;j++)
{
int x=i+,y=j+;
if (Map[i][j]==)
{
sum++;
while (x<n&&y<m&&Map[x][y]!=&&Map[x][y]!=-)
{
if(Map[x][y]==)
Map[x][y]=-;
else
Map[x][y]=;
x++;
y++;
}
}
else if (Map[i][j]==-)
{
sum++;
x=i+,y=j-;
while (x>=&&x<n&&y>=&&y<m&&Map[x][y]!=&&Map[x][y]!=)
{
if(Map[x][y]==)
Map[x][y]=;
else
Map[x][y]=;
x++;
y--;
}
}
else if (Map[i][j]==)
{
sum++;
sum++;
x=i+,y=j-;
while (x<n&&y<m&&Map[x][y]!=&&Map[x][y]!=)
{
if(Map[x][y]==)
Map[x][y]=;
else
Map[x][y]=;
x++;
y--;
}
x=i+,y=j+;
while (x>=&&x<n&&y>=&&y<m&&Map[x][y]!=&&Map[x][y]!=-)
{
if(Map[x][y]==)
Map[x][y]=-;
else
Map[x][y]=;
x++;
y++;
}
}
}
}
printf ("%d\n",sum);
}
return ;
}
hdu 5319 Painter(杭电多校赛第三场)的更多相关文章
- hdu 5326 Work(杭电多校赛第三场)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5326 Work Time Limit: 2000/1000 MS (Java/Others) M ...
- hdu 5373 The shortest problem(杭电多校赛第七场)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5373 The shortest problem Time Limit: 3000/1500 MS (J ...
- hdu 5328 Problem Killer(杭电多校赛第四场)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5328 题目大意:找到连续的最长的等差数列or等比数列. 解题思路:1.等差等比的性质有很多.其中比较重 ...
- HDU 5762 Teacher Bo (鸽笼原理) 2016杭电多校联合第三场
题目:传送门. 题意:平面上有n个点,问是否存在四个点 (A,B,C,D)(A<B,C<D,A≠CorB≠D)使得AB的横纵坐标差的绝对值的和等于CD的横纵坐标差的绝对值的和,n<1 ...
- HDU 5752 Sqrt Bo (思维题) 2016杭电多校联合第三场
题目:传送门. 题意:一个很大的数n,最多开5次根号,问开几次根号可以得到1,如果5次还不能得到1就输出TAT. 题解:打表题,x1=1,x2=(x1+1)*(x1+1)-1,以此类推.x5是不超过l ...
- HDU 5754 Life Winner Bo (各种博弈) 2016杭电多校联合第三场
题目:传送门 题意:一个国际象棋棋盘,有四种棋子,从(n,m)走到(1,1),走到(1,1)的人赢,先手赢输出B,后手赢输出G,平局输出D. 题解:先把从(n,m)走到(1,1)看做是从(1,1)走到 ...
- HDU 4627 The Unsolvable Problem 杭电多校联赛第三场1009 数学题
题意描述:给出一个n,要求在所有满足n = a+b的a和b里面求a和b的最小公倍数最大的两个数的最小公倍数. 解题报告:比赛的时候看到这个题的第一反应就是寻找这两个数一定是在a和b比较接近的地方找,这 ...
- 可持久化线段树的学习(区间第k大和查询历史版本的数据)(杭电多校赛第二场1011)
以前我们学习了线段树可以知道,线段树的每一个节点都储存的是一段区间,所以线段树可以做简单的区间查询,更改等简单的操作. 而后面再做有些题目,就可能会碰到一种回退的操作.这里的回退是指回到未做各种操作之 ...
- HDU 5821 Ball (贪心排序) -2016杭电多校联合第8场
题目:传送门. 题意:T组数据,每组给定一个n一个m,在给定两个长度为n的数组a和b,再给定m次操作,每次给定l和r,每次可以把[l,r]的数进行任意调换位置,问能否在转换后使得a数组变成b数组. 题 ...
随机推荐
- web_config配置
<configuration> <system.web> <compilation debug="true" targetFramew ...
- Java容器深入浅出之List、ListIterator和ArrayList
List是Collection接口的子接口,表示的是一种有序的.可重复元素的集合. List接口的主要实现类ArrayList和Vector,底层都是维护了一套动态的,可扩展长度的Object[]数组 ...
- 九度-题目1195:最长&最短文本
http://ac.jobdu.com/problem.php?pid=1195 题目描述: 输入多行字符串,请按照原文本中的顺序输出其中最短和最长的字符串,如果最短和最长的字符串不止一个,请全部输出 ...
- 【转】史上最浅显易懂的Git教程!
之前一直在找git的学习教程,网上搜到很多,但是大多数写的都非常简单或者混乱,你知道技术男的思维就是以为他抛一个专业术语出来,以为你都懂……或者简单写两句,插个图,他觉得他懂了,你也能懂,事实上初学者 ...
- php简易配置函数
nilcms中:php简易配置函数. 文件位置:nc-admin/common.php /* * --------------------------------------------------- ...
- 转---秒杀多线程第十二篇 多线程同步内功心法——PV操作上 (续)
PV操作的核心就是 PV操作可以同时起到同步与互斥的作用. 1.同步就是通过P操作获取信号量,V操作释放信号量来进行. 2.互斥其实就是,同时操作P操作,结束后进行V操作即可做到. Java上实现PV ...
- BZOJ4972 小Q的方格纸
每个格子记录其左下的45°直角梯形区域的和及左下矩形区域的和即可. #include<iostream> #include<cstdio> #include<cmath& ...
- C++解析(23):多态与C++对象模型
0.目录 1.多态 2.C++对象模型 2.1 使用C语言实现封装 3.继承对象模型 4.多态对象模型 4.1 使用C语言实现多态 5.小结 1.多态 面向对象中期望的行为: 根据实际的对象类型判断如 ...
- 洛谷 P2951 [USACO09OPEN]捉迷藏Hide and Seek
题目戳 题目描述 Bessie is playing hide and seek (a game in which a number of players hide and a single play ...
- 【刷题】BZOJ 2096 [Poi2010]Pilots
Description Tz又耍畸形了!!他要当飞行员,他拿到了一个飞行员测试难度序列,他设定了一个难度差的最大值,在序列中他想找到一个最长的子串,任意两个难度差不会超过他设定的最大值.耍畸形一个人是 ...