# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
341308 |
2020-12-29T12:45:55 Z |
A_D |
Emacs (COCI20_emacs) |
C++14 |
|
2 ms |
512 KB |
/*
ID: antwand1
TASK: pprime
LANG: C++
*/
#include <bits/stdc++.h>
#define ll long long
#define int long long
#define du long double
#define F first
#define S second
#define FOR(a,b) for(int a=1;a<=b;a++)
#define FORl(a,b) for(a=1;a<=b;a++)
#define FOR0(a,b) for(int a=1;a<b;a++)
#define FORl0(a,b) for(a=0;a<b;a++)
using namespace std;
const int N=101;
char a[N][N];
bool vis[N][N];
int n,m;
int x[]={0,0,1,-1};
int y[]={1,-1,0,0};
bool ok(int i,int j)
{
return vis[i][j]==0&&min(i,j)>=1&&j<=m&&i<=n&&a[i][j]=='*';
}
void dfs(int i,int j)
{
vis[i][j]=1;
for(int k=0;k<4;k++){
if(ok(i+x[k],j+y[k]))dfs(i+x[k],j+y[k]);
}
}
main()
{
//freopen("pprime.in","r",stdin);freopen("pprime.out","w",stdout);
cin>>n>>m;
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
cin>>a[i][j];
}
}
int ans=0;
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
if(a[i][j]=='*'&&vis[i][j]==0){
ans++;
dfs(i,j);
}
}
}
cout<<ans<<endl;
}
Compilation message
emacs.cpp:34:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
34 | main()
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
512 KB |
Output is correct |
3 |
Correct |
1 ms |
364 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 |
364 KB |
Output is correct |
8 |
Correct |
1 ms |
492 KB |
Output is correct |
9 |
Correct |
2 ms |
492 KB |
Output is correct |
10 |
Correct |
1 ms |
384 KB |
Output is correct |