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 |
为什么我这题2386能过,1562不能过啊,一样的代码啊!#include<iostream> #include<fstream> using namespace std; const int MAXN = 110; char map[MAXN][MAXN]; int vis[MAXN][MAXN]; void dfs(int x,int y) { if(vis[x][y] == 1 || map[x][y] == '*'|| map[x][y] == 0) return; vis[x][y] = 1; dfs(x-1,y-1);dfs(x-1,y);dfs(x-1,y+1); dfs(x,y-1); dfs(x,y+1); dfs(x+1,y-1);dfs(x+1,y);dfs(x+1,y+1); } int main() { int n,m,cnt; while(cin >> n >> m) { memset(map,0,sizeof(map)); memset(vis,0,sizeof(map)); cnt = 0; if(n == 0)break; for(int i = 1;i <= n;++i) for(int j = 1;j <= m;++j) cin >> map[i][j]; for(int x = 1; x <= n;++x) for(int y = 1;y <= m;++y) if(vis[x][y] == 0 && map[x][y] == '@') { ++cnt; dfs(x,y); } cout << cnt << 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