tuki2501

cco14p1.cpp

Nov 30th, 2021
628
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. typedef long long ll;
  5.  
  6. const int N = 2005;
  7.  
  8. char a[N][N]; ll dp[N][N];
  9.  
  10. signed main() {
  11.   cin.tie(0)->sync_with_stdio(0);
  12.   int n; cin >> n;
  13.   for (int i = 1; i <= n; i++)
  14.   for (int j = 1; j <= n; j++) {
  15.     cin >> a[i][j];
  16.   }
  17.   ll ans = 0;
  18.   for (int i = n; i >= 1; i--)
  19.   for (int j = 1; j <= n; j++) {
  20.     if (a[i][j] == '#') {
  21.       dp[i][j] = min(min(dp[i + 1][j - 1], dp[i + 1][j]), dp[i + 1][j + 1]) + 1;
  22.       ans += dp[i][j];
  23.     }
  24.   }
  25.   cout << ans << '\n';
  26. }
RAW Paste Data