#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
#include <vector>
using namespace std;
int N, M;
char G[3001][3001];
vector<int> D[3001][3001];
long long S;
int main(){
scanf("%d %d", &N, &M);
for (int i = 1; i <= N; i++)
for (int j = 1; j <= M; j++)
scanf(" %c", &G[i][j]);
for (int i = 1; i <= N; i++){
for (int j = 1; j <= M; j++){
if (G[i][j] == 'R'){
int s = D[i - 1][j].size();
for (int k = j; G[i][k] == 'R'; k--){
int d = (j - k < s ? D[i - 1][j][j - k] : 0);
D[i][j].push_back(d + 1);
S += d + 1;
}
}
}
}
printf("%lld", S);
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
36 ms |
221084 KB |
Output is correct |
2 |
Correct |
48 ms |
221084 KB |
Output is correct |
3 |
Correct |
62 ms |
221084 KB |
Output is correct |
4 |
Correct |
30 ms |
221084 KB |
Output is correct |
5 |
Correct |
36 ms |
221084 KB |
Output is correct |
6 |
Correct |
35 ms |
221216 KB |
Output is correct |
7 |
Correct |
40 ms |
221216 KB |
Output is correct |
8 |
Correct |
35 ms |
221348 KB |
Output is correct |
9 |
Correct |
36 ms |
221084 KB |
Output is correct |
10 |
Correct |
24 ms |
221084 KB |
Output is correct |
11 |
Correct |
32 ms |
221084 KB |
Output is correct |
12 |
Correct |
43 ms |
221216 KB |
Output is correct |
13 |
Correct |
20 ms |
221084 KB |
Output is correct |
14 |
Correct |
29 ms |
221084 KB |
Output is correct |
15 |
Correct |
41 ms |
221216 KB |
Output is correct |
16 |
Correct |
27 ms |
221348 KB |
Output is correct |
17 |
Correct |
29 ms |
221084 KB |
Output is correct |
18 |
Correct |
43 ms |
221348 KB |
Output is correct |
19 |
Correct |
39 ms |
221348 KB |
Output is correct |
20 |
Correct |
26 ms |
221216 KB |
Output is correct |
21 |
Correct |
312 ms |
341732 KB |
Output is correct |
22 |
Correct |
150 ms |
251048 KB |
Output is correct |
23 |
Correct |
153 ms |
247088 KB |
Output is correct |
24 |
Correct |
371 ms |
424760 KB |
Output is correct |
25 |
Correct |
344 ms |
418688 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
66 ms |
224120 KB |
Output is correct |
2 |
Correct |
167 ms |
255140 KB |
Output is correct |
3 |
Memory limit exceeded |
493 ms |
524288 KB |
Memory limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |