This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "bits/stdc++.h"
using namespace std;
int main() {
int n, m;
cin >> n >> m;
int grid[n][m];
for (int i=0; i<n; i++) {
string s;
cin >> s;
for (int j=0; j<m; j++) {
grid[i][j] = (s[j] == '.');
}
}
int pf[n+1][m+1];
for (int i=0; i<n+1; i++) pf[i][0] = 0;
for (int i=0; i<m+1; i++) pf[0][i] = 0;
for (int i=0; i<n; i++) {
for (int j=0; j<m; j++) {
pf[i+1][j+1] = pf[i+1][j] + pf[i][j+1] - pf[i][j] + grid[i][j];
}
}
int sm = 0;
for (int i=1; i<=n; i++) {
for (int j=i; j<=n; j++) {
for (int a=1; a<=m; a++) {
for (int b=a; b<=m; b++) {
int area = (j - i + 1) * (b - a + 1);
int qr = pf[j][b] - pf[j][a-1] - pf[i-1][b] + pf[i-1][a-1];
if (area == qr) sm += area;
}
}
}
}
cout << sm << endl;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |