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 <iostream>
#define MAX 3002
char input[MAX][MAX];
int countX[MAX][MAX];
int countY[MAX][MAX];
int N, M, result;
using namespace std;
void count()
{
for (int i = 0; i < N; i++) {
for (int j = 0; j < M; j++) {
if (input[i][j] == 'R') {
if (j == 0) countX[i][j] = 1;
else countX[i][j] = countX[i][j - 1] + 1;
if (i == 0) countY[i][j] = 1;
else countY[i][j] = countY[i - 1][j] + 1;
}
else countX[i][j] = countY[i][j] = 0;
}
}
}
void solve()
{
result = 0;
int min;
for (int i = 0; i < N; i++) {
for (int j = 0; j < M; j++) {
min = MAX;
for (int k = 0; k < countX[i][j]; k++) {
if (min > countY[i][j - k]) min = countY[i][j - k];
result += min;
}
}
}
}
int main(int argc, char** argv)
{
ios::sync_with_stdio(false);
cin >> N >> M;
for (int i = 0; i < N; i++) {
cin >> input[i];
}
count();
solve();
cout << result << endl;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |