This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <map>
#define PII pair<int, int>
using namespace std;
int N, M;
char G[3001][3001];
map<PII, int> D;
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]);
G[i][j] = (G[i][j] == 'R');
}
}
for (int i = 1; i <= N; i++){
for (int j = 1; j <= M; j++){
if (G[i][j] == 1){
for (int k = j; G[i][k] == 1; k--){
int d = D[PII((i - 1) * (M + 1) + j, j - k)];
D[PII(i * (M + 1) + j, j - k)] = d + 1;
S += d + 1;
}
}
}
}
printf("%lld", S);
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |