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