Advertisement
Josif_tepe

Untitled

Apr 24th, 2022
1,175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.16 KB | None | 0 0
  1. #include <iostream>
  2. #include <algorithm>
  3. #include <set>
  4. #include <vector>
  5. #include <map>
  6. #include <fstream>
  7. #include <set>
  8. #include <cmath>
  9. using namespace std;
  10. char mat[2005][2500];
  11. int main(){
  12.     int n, m, k;
  13.     cin >> n >> m >> k;
  14.     for(int i = 0; i < n; i++) {
  15.         for(int j = 0; j < m; j++) {
  16.             cin >> mat[i][j];
  17.         }
  18.     }
  19.     long long result = 0;
  20.     for(int i = 0; i < n; i++) {
  21.         int consecutive = 0;
  22.         for(int j = 0; j < m; j++) {
  23.             if(mat[i][j] == '.') {
  24.                 consecutive++;
  25.             }
  26.             if(mat[i][j] == '*' or j == m - 1) {
  27.                 result += max(0, consecutive - k + 1);
  28.                 consecutive = 0;
  29.             }
  30.         }
  31.     }
  32.     if(k != 1) {
  33.     for(int i = 0; i < m; i++) {
  34.         int consecutive = 0;
  35.         for(int j = 0; j < n; j++) {
  36.             if(mat[j][i] == '.') {
  37.                 consecutive++;
  38.             }
  39.             if(mat[j][i] == '*' or j == n - 1) {
  40.                 result += max(0, consecutive - k + 1);
  41.                 consecutive = 0;
  42.             }
  43.         }
  44.     }
  45.     }
  46.     cout << result << endl;
  47.     return 0;
  48. }
  49.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement