Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

跪求求大神指导!测了多数据了,都过了,为啥WA ??????

Posted by bj921712230 at 2013-04-21 20:31:42 on Problem 1562
#include<stdio.h>
#include<iostream>
#include<string>
using namespace std;
int main(){
	int i,j,count,r,c;
	char b;

	while (scanf("%d%d",&r,&c)&&(r!=0||c!=0)){
		int a[110][110];
        getchar();
		count=1;

		for(i=0;i<=r;i++)
		    for(j=0;j<=c+1;j++){
                    if(j==0){a[i][j]=-1;j++;}
            if(i==r||j==c+1) a[i][j]=-1;
            else{
                cin>>b;
				if(b=='@') a[i][j]=0;
				else a[i][j]=-1;
				}
    		}

     for(i=0;i<r;i++)
        for(j=1;j<=c;j++)
     {
         if(a[i+1][j-1]>0&&a[i][j]==0) a[i][j]=a[i+1][j-1];
         if(a[i][j]==0||a[i][j]>0)
         {
             if(a[i][j]==0) count++;
             a[i][j]=count;
            if(a[i+1][j-1]==0) a[i+1][j-1]=a[i][j];
            if(a[i+0][j+1]==0) a[i+0][j+1]=a[i][j];
            if(a[i+1][j+0]==0) a[i+1][j+0]=a[i][j];
            if(a[i+1][j+1]==0) a[i+1][j+1]=a[i][j];
         }
     }



		printf("%d\n",count-1);
	}
    return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator