# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
340089 |
2020-12-26T21:19:12 Z |
Hazem |
Emacs (COCI20_emacs) |
C++14 |
|
1 ms |
876 KB |
/*
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
emacs.cpp: In function 'int main()':
emacs.cpp:42:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
42 | scanf("%d%d",&n,&m);
| ~~~~~^~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
748 KB |
Output is correct |
2 |
Correct |
1 ms |
748 KB |
Output is correct |
3 |
Correct |
1 ms |
876 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
1 ms |
748 KB |
Output is correct |
8 |
Correct |
1 ms |
748 KB |
Output is correct |
9 |
Correct |
1 ms |
748 KB |
Output is correct |
10 |
Correct |
1 ms |
748 KB |
Output is correct |