# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1101767 | rayan_bd | Emacs (COCI20_emacs) | C++17 | 1 ms | 468 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.
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
#define getar(ar,n) for(ll i=0;i<n;++i) cin>>ar[i]
#define show(n) cout<<n<<'\n'
#define all(v) v.begin(), v.end()
#define br cout<<"\n"
#define pb push_back
#define nl '\n'
#define yes cout<<"YES\n"
#define no cout<<"NO\n"
#define ret return
#define ll long long
#define ld long double
#define sza(x) ((int)x.size())
const int mxN = 105;
const ll MOD = 1e9 + 7;
const ll INF = 1e9;
const ld EPS = 1e-9;
char grid[mxN][mxN];
void dfs(ll i,ll j){
if(grid[i][j]=='.') return;
grid[i][j]='.';
dfs(i+1,j);
dfs(i-1,j);
dfs(i,j+1);
dfs(i,j-1);
}
void solve() {
ll n,m;cin>>n>>m;
memset(grid,'.',sizeof(grid));
string str;
for(ll i=1;i<=n;++i){
cin>>str;
for(ll j=1;j<=m;++j){
grid[i][j]=str[j-1];
}
}
ll ans=0;
for(ll i=1;i<=n;++i){
for(ll j=1;j<=m;++j){
if(grid[i][j]=='*'){
dfs(i,j);
++ans;
}
}
}
show(ans);
}
signed main() {
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
solve();
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |