| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
为什么WA?#include <stdio.h>
int a,b;
char map[1000][1000];
int result[1000][1000];
void work(int p,int q,int r,int t)
{
if(r>=0 && r<a && t>=0 && t<b)
if(map[r][t]=='W' && result[r][t])
result[p][q]=result[r][t];
}
int main()
{
int s;
char message[1000];
int i,j;
scanf("%d%d",&a,&b);
for(i=0;i<a;i++)
for(j=0;j<b;j++)
result[i][j]=0;
for(i=0;i<a;i++){
scanf("%s",&message);
for(j=0;j<b;j++)
map[i][j]=message[j];
}
s=0;
for(i=0;i<a;i++)
for(j=0;j<b;j++)
if(map[i][j]=='W'){
work(i,j,i-1,j);
work(i,j,i-1,j-1);
work(i,j,i,j-1);
work(i,j,i+1,j-1);
work(i,j,i+1,j);
work(i,j,i-1,j+1);
work(i,j,i,j+1);
work(i,j,i+1,j+1);
if(!result[i][j])
result[i][j]=++s;
}
printf("%d\n",s);
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator