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数组. 题 ...
随机推荐
- Django内置的分页模块
自定义分页 未封装版: 优点:直观 缺点:代码乱,不易维护,可拓展性差 data = [] for i in range(1, 302): tmp = {"id": i, &quo ...
- application/x-www-form-urlencoded 与 application/json区别
两种请求方式对服务器端都没什么影响 application/x-www-form-urlencoded方式是比较老的一种方式,这种方式的好处就是浏览器都支持, 在请求发送过程中会对数据进行序列化处理, ...
- Delphi通过ADO链接数据库及对数据库的增加,删除,修改,读取操作实例教程4
ADO是一种程序对象,用于表示用户数据库中的数据结构和所包含的数据.ADO(ActiveXDataObjects,ActiveX数据对象)是Microsoft提出的应用程序接口(API)用以实现访问关 ...
- TClientDataSet[5]: 读取数据
本例用到: TClientDataSet.Fields[]; { 字段集合; 它比 FieldList 有更多功能, 如可获取嵌套字段 } TClientDataSet.FieldL ...
- 如何让TEdit在获取输入焦点后selectAll?
关于网友提出的“ 如何让TEdit在获取输入焦点后selectAll?”问题疑问,本网通过在网上对“ 如何让TEdit在获取输入焦点后selectAll?”有关的相关答案进行了整理,供用户进行参考,详 ...
- 【bzoj5183】[Baltic2016]Park 离线+对偶图+并查集
题目描述 在Byteland的首都,有一个矩形围栏围起来的公园.在这个公园里树和访客都以一个圆形表示.公园有四个出入口,每个角落一个(1=左下角,2=右下角,3=右上角,4=左上角).访客能通过这些出 ...
- ZendFramework安装配置
1.创建项目目录 E:/wwwroot/myzfpro 运行cmd后,cd到框架源文件的bin目录 运行zf.bat创建命令:zf.bat create project E:/wwwroot/myzf ...
- 在github fork的项目中推送与抓取
github -- fork提交项目:自己的仓库和原仓库进行Git同步的操作. 1. 获取你fork的原仓库的更新过的最新代码:如果没有远程原始分支则需要增加. git remote add upst ...
- vector 和数组 之间的转化
1.数组转vector float arrHeight[] = { 1.68,1.72,1.83,2.05,2.35,1.78,2.1,1.96 }; vector<float> vec ...
- CentOS 7网络故障
By francis_hao Nov 2,2017 在像往常一样打开了虚拟机后,打开xshell准备连接到centos,可是连不上,发现连接的网卡没有启动,使用systemctl启动netw ...