#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;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
81384 KB |
Output is correct |
2 |
Correct |
0 ms |
81384 KB |
Output is correct |
3 |
Correct |
0 ms |
81384 KB |
Output is correct |
4 |
Correct |
0 ms |
81384 KB |
Output is correct |
5 |
Correct |
0 ms |
81384 KB |
Output is correct |
6 |
Correct |
0 ms |
81384 KB |
Output is correct |
7 |
Correct |
0 ms |
81384 KB |
Output is correct |
8 |
Correct |
0 ms |
81384 KB |
Output is correct |
9 |
Correct |
0 ms |
81384 KB |
Output is correct |
10 |
Correct |
0 ms |
81384 KB |
Output is correct |
11 |
Correct |
0 ms |
81384 KB |
Output is correct |
12 |
Correct |
0 ms |
81384 KB |
Output is correct |
13 |
Correct |
0 ms |
81384 KB |
Output is correct |
14 |
Correct |
0 ms |
81384 KB |
Output is correct |
15 |
Correct |
0 ms |
81384 KB |
Output is correct |
16 |
Correct |
0 ms |
81384 KB |
Output is correct |
17 |
Correct |
0 ms |
81384 KB |
Output is correct |
18 |
Correct |
0 ms |
81384 KB |
Output is correct |
19 |
Correct |
0 ms |
81384 KB |
Output is correct |
20 |
Correct |
0 ms |
81384 KB |
Output is correct |
21 |
Correct |
33 ms |
81384 KB |
Output is correct |
22 |
Correct |
6 ms |
81384 KB |
Output is correct |
23 |
Correct |
6 ms |
81384 KB |
Output is correct |
24 |
Correct |
49 ms |
81384 KB |
Output is correct |
25 |
Correct |
46 ms |
81384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
81384 KB |
Output is correct |
2 |
Correct |
6 ms |
81384 KB |
Output is correct |
3 |
Incorrect |
183 ms |
81384 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |