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 <stdio.h>
#include <stdlib.h>
#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]);
	for (int i = 1; i <= N; i++){
		for (int j = 1; j <= M; j++){
			if (G[i][j] == 'R'){
				for (int k = j; G[i][k] == 'R'; 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... |