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 |
太恶心了 1562就过了 为什么这个过不了??????????????大牛看看啊 wa哭了#include<iostream> using namespace std; int sum = 0; int num[10000][10000] = {0}; char teststr[10000][10000]; void search(int x,int y){ num[x][y] = 0; if(num[x + 1][y] == 1){ search(x + 1,y); } if(num[x][y + 1] == 1){ search(x,y + 1); } if(num[x - 1][y] == 1){ search(x - 1,y); } if(num[x][y - 1] == 1){ search(x,y - 1); } if(num[x + 1][y - 1] == 1){ search(x + 1,y - 1); } if(num[x + 1][y + 1] == 1){ search(x + 1,y); } if(num[x - 1][y - 1] == 1){ search(x - 1,y - 1); } if(num[x - 1][y + 1] == 1){ search(x - 1,y + 1); } return; } int main() { int i,j; int x,y; memset(num,0,2 * sizeof(int)); // freopen("2386.txt","r",stdin); cin>>x>>y; for(i = 0; i < x; i++){ cin>>teststr[i]; } for(i = 0; i < x; i++){ for(j = 0; j < y; j++){ if(teststr[i][j] == 'W'){ num[i + 1][j + 1] = 1; } else{ num[i + 1][j + 1] = 0; } } } for(i = 1; i <= x; i++){ for(j = 1; j <= y; j++){ if(num[i][j] == 1){ sum++; search(i,j); } } } cout<<sum<<endl; return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator