| Run ID | Author | Problem | Lang | Verdict | Score | Time | Memory | Code Length | Submit Time |
|---|---|---|---|---|---|---|---|---|---|
| 57339 | 陈思雨 | 家族 | C++ | Wrong Answer | 0 | 0 MS | 264 KB | 595 | 2022-08-05 13:28:32 |
#include<bits/stdc++.h> using namespace std; const int dx[4]={-1,0,1,0},dy[4]={0,1,0,-1}; int n,ans; string s[100]; bool check(int x,int y){ return x>=0&&x<n&&y>=0&&y<s[x].size()&&s[x][y]>='a'&&s[x][y]<='z'; } void dfs(int x,int y){ s[x][y]='*'; for(int i=0;i<4;i++){ int tx=x+dx[i],ty=y+dy[i]; if(check(tx,ty)) dfs(tx,ty); } } int main(){ cin>>n; getchar; for(int i=0;i<n;i++) getline(cin,s[i]); for(int i=0;i<n;i++){ for(int j=0;j<s[i].size();j++){ if(s[i][j]>='a'&&s[i][j]<='z'){ dfs(i,j); ans++; } } } cout<<ans; return 0; }