제출 #15076

#제출 시각아이디문제언어결과실행 시간메모리
15076sujin빨간 직사각형 (kriii3_QQ)C++14
0 / 20
1000 ms291032 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...