Run ID 作者 问题 语言 测评结果 分数 时间 内存 代码长度 提交时间
15517 D班-西瓜 有多少细胞 C++ 编译错误 0 0 MS 0 KB 454 2026-03-07 20:03:05

Tests(0/0):


#include<bits/stdc++.h> using namespace std; const int N=1e5; int 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(int 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(int i=1; i<=n; i++) { for(int j=1; j<=m; j++) { cin>>a[i][j]; } } dfs(1,1); cout<<s; }


测评信息: