hdu  The window of the dazzling

The window of the dazzling

Problem Description

Now that spring is here and the sun is shining bright, people are starting to lower their blinds. Stefica is an elderly woman who likes to keep track of what other people in the neighbourhood are doing and then talk about it behind their backs. This year, she is particularly interested in who is lowering blinds in the building across the street, and how low are they lowering them. We will represent each window with a 4 x 4 grid, with asteriskes representing lowered blinds. Stefica can see a window in one of the following 5 states: 
hdu  The window of the dazzling
The building across the street has N windows at each of the M floors. Given the current building state, find out how many windows are in each of the 5 states shown above.

Input

The input consists of multiple test cases.The first line of input contains space separated integers M and N (1 ≤ M, N ≤ 100). The following lines describe the current building state. Each window is represented with one of the 4 x 4 grids shown above, and windows are separated using character '#'. See the example input for clarification. Building description will have exactly 5M + 1 lines each having 5N + 1 characters.

Output

Output should contain 5 space separated integers, number of windows for each type in order shown above. Sum of these numbers is M*N.

Sample Input

1 2

###########

#....#****#

#....#****#

#....#....#

#....#....#

###########

2 3

################

#****#****#****#

#****#****#****#

#****#....#****#

#....#....#****#

################

#....#****#****#

#....#****#....#

#....#....#....#

#....#....#....#

################

Sample Output

1 0 1 0 0

1 1 2 1 1

Source

2012暑假集训
 
AC代码

#include <stdio.h>
#include <string.h>
#define maxn 550
char a[maxn][maxn];
int sol[maxn];
int main( )
{
int n,m;

int i,j;
while(scanf("%d%d",&m,&n)!=EOF)
{
     memset(sol,0,sizeof(sol));
     for( i=0;i<5*m+1;i++) scanf("%s",a[i]);
     for( i=0;i<m;i++)
     {
        for( j=0;j<n;j++)
        {
         int x=1+5*i;
         int y=1+5*j;
         int k=0;
         for( int l=0;l<4;l++)
         {
            k+=(a[x+l][y]=='*');
         }
         sol[k]++;
     }
     }
     for( i=0;i<5;i++)
     {
        printf("%d%c",sol[i],i==4?'\n':' ');
     }
}
return 0;

}

 链接:http://acm.hdu.edu.cn/diy/contest_showproblem.php?cid=16309&pid=1008

你可能感兴趣的:(window)