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> #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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator