Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <algorithm>
- #include <set>
- #include <vector>
- #include <map>
- #include <fstream>
- #include <set>
- #include <cmath>
- using namespace std;
- char mat[2005][2500];
- int main(){
- int n, m, k;
- cin >> n >> m >> k;
- for(int i = 0; i < n; i++) {
- for(int j = 0; j < m; j++) {
- cin >> mat[i][j];
- }
- }
- long long result = 0;
- for(int i = 0; i < n; i++) {
- int consecutive = 0;
- for(int j = 0; j < m; j++) {
- if(mat[i][j] == '.') {
- consecutive++;
- }
- if(mat[i][j] == '*' or j == m - 1) {
- result += max(0, consecutive - k + 1);
- consecutive = 0;
- }
- }
- }
- if(k != 1) {
- for(int i = 0; i < m; i++) {
- int consecutive = 0;
- for(int j = 0; j < n; j++) {
- if(mat[j][i] == '.') {
- consecutive++;
- }
- if(mat[j][i] == '*' or j == n - 1) {
- result += max(0, consecutive - k + 1);
- consecutive = 0;
- }
- }
- }
- }
- cout << result << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement