[Fzyzoj 1867] Zgg Aurora Viewing

Source: Internet
Author: User

P1867--Zgg Aurora viewing

Time limit: 1000MS memory limit: 131072KB Pass/Submit number: 55/97

Status: Accepted Tags: search-deep searching no no

Description

Zhang Geg and his sisters came to the Arctic Christmas zone, which is almost 12 o ' notice. It is said that the Aurora show will begin. The aurora borealis is not a polar-specific natural aurora borealis scene. But the artificial aurora.

Thundered...... Fireworks sounded. Then there's the Aurora show.

The man-made Aurora is actually a dot-n*m image in the air. Just because it is particularly bright and attracts a lot of many eyes, also became the most beautiful Christmas Eve moment.

However, in each n*m bitmap image, each point has only two states: luminous and non-luminous. For all the glowing dots, a beautiful picture is formed in the air. And this picture is made up of several (s) patterns. For the pattern, there is a strict definition: for the two illuminated points, if their Manhattan distance (for a (x1,y1) and B (X2,y2), A and b between the Manhattan distance of |x1-x2|+|y1-y2|) is less than or equal to 2. Then these two points belong to a pattern ...
While admiring the aurora, the girls counted the number of patterns in each aurora image. A beautiful Christmas night accompanied by singing and dancing.

Input Format

The first line, two numbers n and M.

Next, there are N rows, with m characters per line. For the J-character of line I, if it is "-", then it indicates that the point does not glow, and if it is "#", then the point glows. Other characters cannot be present.

Output Format

The first line, a number s. Represents the number of patterns.

Sample Input
--#-----#---------------------######---########--#-#---#-#####--#-##-##---#--########--###--###--#-#---#-#----# -##-##--#--#--###--###--###--###--#--#-#--######-#--#---#-#---###--###--########--#--#-#--#------#--#----##---# #######---######---#---#---######-#--#-----#----######-----####----------------------------#-----####---------- ---------------------------#----------------------------------------------------------------###--#--------#---- --#-------------------------#---#-#---------------#------------------------#------#-##--#-##--##-###-#-##-###-- ###-#--##---#------##--#-##-#-#----#--##--#---##---##-#-----#------#---#-#--#--#---#--#---#---##----#--#-----#- --#-#---#-#--#---#--#--#---#---##---##---#-----###--#---#-#--#-##---#--#---#---#-###-#-##---------------------- -----------------------------
Sample Output
4
Hint

1<=n,m<=100

"Solving" qaq plus optimization are not optimized fast, practice search Basic skills: Special connected blocks

1#include <bits/stdc++.h>2 using namespacestd;3 Chara[101][101];4 Charb[1<< the],*s=b,*t=B;5 intdx[]={0,0,0,0,1,2,-1,-2,-1,1,-1,1};6 intdy[]={-1,-2,1,2,0,0,0,0,-1,1,1,-1};7 intn,m,cnt;8 Chargetchar2 () {9     returns==t&& (t= (s=b) +fread (B,1,1<< the, stdin), s==t)?0:* s++;Ten } One intRead () { A     intx=0, f=1; -     CharCh=getchar2 (); -      while(ch<'0'|| Ch>'9') {if(ch=='-') f=-1; Ch=getchar2 ();} the      while(ch>='0'&&ch<='9') {x=x*Ten+ch-'0'; Ch=getchar2 ();} -     returnx*F; - } - voidFilledintXinty) { +a[x][y]='-'; -     intXx,yy; +      for(intI=0; i<= One;++i) { Axx=x+dx[i],yy=y+Dy[i]; at         if(a[xx][yy]=='#'&&xx>=1&&yy>=1&&xx<=n&&yy<=m) filled (xx,yy); -     }     - } - intMain () { -N=read (); m=read (); -      for(intI=1; i<=n;++i) { in          for(intj=1; j<=m;++j) a[i][j]=getchar2 (); - getchar2 (); to     } +      for(intI=1; i<=n;++i) printf ("%s", A[i]); -      for(intI=1; i<=n;++i) the          for(intj=1; j<=m;++j) *             if(a[i][j]=='#') { $cnt++;Panax Notoginseng filled (i,j); -             } theprintf"%d\n", CNT); +     return 0; A}
View Code

[Fzyzoj 1867] Zgg Aurora Viewing

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.