hdu 5319 Painter 2015 Multi-University Training Contest 3
来源:互联网 发布:腾讯来电软件怎么回事 编辑:程序博客网 时间:2024/05/01 09:02
Painter
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 587 Accepted Submission(s): 275
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.
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
24RR.B.RG..BRRB..R4RRBBRGGBBGGRBBRR
Sample Output
36
Source
2015 Multi-University Training Contest 3
Recommend
wange2014 | We have carefully selected several similar problems for you: 5326 5325 5324 5323 5322
#include<cstdio>#include<string>#include<cstring>#include<iostream>#include<cmath>#include<algorithm>#include<climits>#include<queue>#include<vector>#include<map>#include<sstream>#include<set>#include<stack>#include<utility>//#pragma comment(linker, "/STACK:102400000,102400000")#define INF 0x3f3f3f3f#define PI 3.1415926535897932384626#define eps 1e-10#define sqr(x) ((x)*(x))#define FOR0(i,n) for(int i=0 ;i<(n) ;i++)#define FOR1(i,n) for(int i=1 ;i<=(n) ;i++)#define FORD(i,n) for(int i=(n) ;i>=0 ;i--)#define lson num<<1,l,mid#define rson num<<1|1,mid+1,r#define MID int mid=(l+r)>>1#define zero(x)((x>0? x:-x)<1e-15)using namespace std;const int maxn= 50+5 ;//const int maxm= ;//const int INF= ;//typedef long long ll;//ifstream fin("input.txt");//ofstream fout("output.txt");//fin.close();//fout.close();//freopen("a.in","r",stdin);//freopen("a.out","w",stdout);char a[maxn][maxn];int red[maxn][maxn];int blue[maxn][maxn];int n;int m;bool in(int &y,int &x){ return 1<=y&&y<=n&&1<=x&&x<=m;}/*int solveblue( ) 我写的,虽然比较麻烦{ int ans=0; for(int stx=1;stx<=m+n-1;stx++) { int sty=1; bool has=0; for(int y=1,x=stx;y<=n;y++,x--) { if(!in(y,x) ) continue; if(blue[y][x]&&has==0) {ans++; has=1; } else if(!blue[y][x]) { has=0; } } } return ans;}int solvered(){ int ans=0; for(int stx=2-n;stx<=m;stx++) { int sty=1; bool has=0; for(int y=sty,x=stx;y<=n;y++ ,x++ ) { if(!in(y,x) ) continue; if(red[y][x]&&has==0) {has=1;ans++;} else if(!red[y][x]) { has=0; } } } return ans;}*/int solveblue() //队友的找法,我写了一遍{ int ans=0; for(int i=1;i<=n;i++) { for(int j=1;j<=m;j++) { int y=i-1,x=j+1; if(blue[i][j]&& (!in(y,x)||!blue[y][x]) ) ans++; } } return ans;}int solvered(){ int ans=0; for(int i=1;i<=n;i++) { for(int j=1;j<=m;j++) { int y=i-1,x=j-1; if(red[i][j]&& (!in(y,x)||!red[y][x]) ) ans++; } } return ans;}int main(){ int i,j; int T; scanf("%d",&T); while(T--) { memset(blue,0,sizeof blue); memset(red,0,sizeof red); scanf("%d",&n); for(int i=1;i<=n;i++) { scanf(" %s",a[i]+1); m=strlen(a[i]+1); for(int j=1;j<=m;j++) { if(a[i][j]=='G') blue[i][j]=1,red[i][j]=1; else if(a[i][j]=='R') red[i][j]=1; else if(a[i][j]=='B') blue[i][j]=1; } } int ans=0;// cout<<"sd"<<endl; ans+= solveblue( ); ans+=solvered();// cout<<"sd"<<endl; printf("%d\n",ans); } return 0;}/*24RR.B.RG..BRRB..R4RRBBRGGBBGGRBBRR*/
0 0
- hdu 5319 Painter 2015 Multi-University Training Contest 3
- hdu 5319 Painter 2015 Multi-University Training Contest 3
- HDU 5319 Painter (2015 Multi-University Training Contest 3 2015多校联合)
- HDU 5319 Painter(模拟 + 规律)——2015 Multi-University Training Contest 3
- 2015 Multi-University Training Contest 3 1004 painter
- hdu 5316 Magician(2015 Multi-University Training Contest 3)
- HDU 5316 Magician(2015 Multi-University Training Contest 3 1001)
- hdu 5317 RGCDQ 2015 Multi-University Training Contest 3
- hdu-5316 Magician (2015 Multi-University Training Contest 3)
- hdu-5325 Crazy Bobo (2015 Multi-University Training Contest 3)
- hdu 5316 Magician 2015 Multi-University Training Contest 3
- hdu 5326 Work 2015 Multi-University Training Contest 3
- hdu 5317 RGCDQ 2015 Multi-University Training Contest 3
- hdu 5316 Magician 2015 Multi-University Training Contest 3
- 2015 Multi-University Training Contest 3
- 2015 Multi-University Training Contest 3
- 2015 Multi-University Training Contest 3 RGCDQ
- 2015 Multi-University Training Contest 3
- JSP入门
- 菜鸟的安卓实习之路---微信悬浮窗通知窗口怎么做怎么做?
- eclipse错误:java was started but returned exit code=-1073741510
- Foundation Framework 基本数据封装 NSNumber、NSValue、NSData
- AndroidMaterialDesign动画之Activity Transitions
- hdu 5319 Painter 2015 Multi-University Training Contest 3
- c# 反射
- 简单实用的 Ubuntu 快捷键
- 如何成为受市场欢迎的Android开发
- kettle各组件说明
- 分布式文件系统试用比较
- ORACLE索引详解
- 工具推荐:爱内测产品全新升级改版,让你惊喜不断
- FreeRTOS 学习笔记 2 —— 创建任务