| Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
|---|---|---|---|---|---|---|---|---|---|
| 15516 | D班-西瓜 | 有多少细胞 | C++ | 编译错误 | 0 | 0 MS | 0 KB | 446 | 2026-03-07 20:02:19 |
#include<bits/stdc++.h> using namespace std; const int N=1e5; int i,j,n,m,s,tx,ty; char a[N][N]; int fx[4]= {1,-1,0,0}; int fy[4]= {0,0,1,-1}; void dfs(int x,int y) { for(i=0; i<4; i++) { tx=x + fx[i]; ty=y + fy[i]; if(tx>0&&tx<=n&&ty>0&&ty<=m&&a[tx][ty]!='0') { dfs(tx,ty); s++; } } } int main() { cin>>n>>m; for(i=1; i<=n; i++) { for(j=1; j<=m; j++) { cin>>a[i][j]; } } dfs(1,1); cout<<s; }