| Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
|---|---|---|---|---|---|---|---|---|---|
| 15481 | 陈颖钧 | 数池塘(四方向) | C++ | 通过 | 100 | 2 MS | 264 KB | 520 | 2026-02-06 09:05:13 |
#include<bits/stdc++.h> using namespace std; int n,m,i,j,tx,ty,s; char a[110][110]; int fx[4]={-1,1,0,0}; int fy[4]={0,0,-1,1}; void dfs(int x,int y){ a[x][y]='.'; for(int k=0;k<4;k++){ tx=x+fx[k]; ty=y+fy[k]; if(tx>=1&&tx<=n&&ty>=1&&ty<=m&&a[tx][ty]=='W'){ dfs(tx,ty); } } } int main(){ cin>>n>>m; for(i=1;i<=n;i++){ for(j=1;j<=m;j++){ cin>>a[i][j]; } } for(i=1;i<=n;i++){ for(j=1;j<=m;j++){ if(a[i][j]=='W'){ dfs(i,j); s++; } } } cout<<s; }