标签:des script res idt rate where tail lower present
Time Limit: 1000MS | Memory Limit: 65536K | |
Total Submissions: 37384 | Accepted: 18586 |
Description
Input
Output
Sample Input
10 12
W........WW.
.WWW.....WWW
....WW...WW.
.........WW.
.........W..
..W......W..
.W.W.....WW.
W.W.W.....W.
.W.W......W.
..W.......W.
Sample Output
3
Hint
#include <iostream> using namespace std; typedef long long ll; char a[110][110]; int m,n; void dfs(int x ,int y){ if(x < 0||x >= n||y < 0||y >= m){ return; } a[x][y] = ‘.‘; for(int i = -1;i <= 1; i++){ for(int j = -1;j <= 1; j++){ if(a[x+i][y+j] == ‘W‘){ dfs(x+i,y+j); } } } return; } int main() { int ans = 0; cin >> n >> m; for(int i = 0;i < n; i++){ for(int j = 0;j < m; j++){ cin >> a[i][j]; } } for(int i = 0;i < n; i++){ for(int j = 0;j < m; j++){ if(a[i][j] == ‘W‘){ dfs(i,j); ans++; } } } cout << ans << endl; return 0; } // writen by zhangjiuding
标签:des script res idt rate where tail lower present
原文地址:http://www.cnblogs.com/zhangjiuding/p/7663397.html