Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- typedef long long ll;
- const int N = 2005;
- char a[N][N]; ll dp[N][N];
- signed main() {
- cin.tie(0)->sync_with_stdio(0);
- int n; cin >> n;
- for (int i = 1; i <= n; i++)
- for (int j = 1; j <= n; j++) {
- cin >> a[i][j];
- }
- ll ans = 0;
- for (int i = n; i >= 1; i--)
- for (int j = 1; j <= n; j++) {
- if (a[i][j] == '#') {
- dp[i][j] = min(min(dp[i + 1][j - 1], dp[i + 1][j]), dp[i + 1][j + 1]) + 1;
- ans += dp[i][j];
- }
- }
- cout << ans << '\n';
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement