# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
340089 | Hazem | Emacs (COCI20_emacs) | C++14 | 1 ms | 876 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
/*
ID: tmhazem1
LANG: C++14
TASK: pprime
*/
#include <bits/stdc++.h>
using namespace std;
#define S second
#define F first
#define LL long long
const int N = 3e3 + 10;
LL LINF = 100000000000000000;
LL INF = 1000000000;
string s[N];
bool vis[N][N];
int x[]={1,-1,0,0};
int y[]={0,0,1,-1};
int n,m;
int dfs(int i,int j){
if(vis[i][j]||s[i][j]=='.')return 0;
vis[i][j] = 1;
for(int k=0;k<4;k++){
int i1 = i+x[k],j1 = j+y[k];
if(i1>=1&&j1>=0&&i1<=n&&j1<m)
dfs(i1,j1);
}
return 1;
}
int main()
{
//freopen("out.txt","w",stdout);
scanf("%d%d",&n,&m);
for(int i=1;i<=n;i++)
cin>>s[i];
int ans = 0;
for(int i=1;i<=n;i++)
for(int j=0;j<m;j++)
ans += dfs(i,j);
printf("%d\n",ans);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |