Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int main(){
- ios_base::sync_with_stdio(0), cin.tie(0);
- // freopen("puddles.in", "r", stdin);
- int n, m;
- cin >> n >> m;
- string val;
- char pos[n][m];
- for(int i=0; i<n; i++){
- cin >> val;
- for(int j=0; j<m; j++){
- pos[i][j] = val[j];
- }
- }
- int ans = 0;
- for(int i=0; i<n; i++){
- for(int j=0; j<m; j++){
- if(pos[i][j] == '#'){
- ans++;
- if(j+1<m && pos[i][j+1] == '#'){
- pos[i][j+1] = '.';
- }
- if(i+1<n && pos[i+1][j] == '#'){
- pos[i+1][j] = '.';
- }
- }
- }
- }
- cout << ans << '\n';
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement