| Run ID | Author | Problem | Lang | Verdict | Score | Time | Memory | Code Length | Submit Time |
|---|---|---|---|---|---|---|---|---|---|
| 15470 | 陈颖钧 | 奶牛和草丛 | C++ | Accepted | 100 | 0 MS | 256 KB | 530 | 2026-02-05 11:40:13 |
#include<bits/stdc++.h> using namespace std; char s[110][110]; int r,c,su,tx,ty; int fx[4]={-1,1,0,0}; int fy[4]={0,0,-1,1}; void f(int x,int y){ s[x][y]='.'; for(int k=0;k<4;k++){ tx=x+fx[k]; ty=y+fy[k]; if(tx>=1&&tx<=r&&ty>=1&&ty<=c&&s[tx][ty]=='#'){ f(tx,ty); } } } int main(){ cin>>r>>c; for(int i=1;i<=r;i++){ for(int j=1;j<=c;j++){ cin>>s[i][j]; } } for(int i=1;i<=r;i++){ for(int j=1;j<=c;j++){ if(s[i][j]=='#'){ f(i,j); su++; } } } cout<<su; }