답안 #15115

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
15115 2015-07-11T10:41:24 Z cki86201 빨간 직사각형 (kriii3_QQ) C++
20 / 20
254 ms 45120 KB
#include<stdio.h>

char p[3002][3002];
int c[3002][3002], s[3002][2], d[3002];
long long ans;

int main(){
	int n, m;
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= n; i++)scanf("%s", p[i]+1);
	for (int i = 1; i <= n; i++){
		for (int j = 1, now = 0; j <= m; j++){
			if (p[i][j] == 'R')c[i][j] = ++now;
			else now = 0;
		}
	}
	for (int i = 1; i <= m; i++){
		for (int j = 1, top = 0; j <= n + 1; j++){
			while (top && s[top - 1][1] >= c[j][i])--top;
			if (top)d[j] = d[s[top - 1][0]] + (j - s[top - 1][0]) * c[j][i];
			else d[j] = c[j][i] * j;
			s[top][0] = j, s[top++][1] = c[j][i];
			ans += d[j];
		}
	}
	printf("%lld", ans);
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 45120 KB Output is correct
2 Correct 0 ms 45120 KB Output is correct
3 Correct 0 ms 45120 KB Output is correct
4 Correct 0 ms 45120 KB Output is correct
5 Correct 0 ms 45120 KB Output is correct
6 Correct 0 ms 45120 KB Output is correct
7 Correct 0 ms 45120 KB Output is correct
8 Correct 0 ms 45120 KB Output is correct
9 Correct 0 ms 45120 KB Output is correct
10 Correct 0 ms 45120 KB Output is correct
11 Correct 0 ms 45120 KB Output is correct
12 Correct 0 ms 45120 KB Output is correct
13 Correct 0 ms 45120 KB Output is correct
14 Correct 0 ms 45120 KB Output is correct
15 Correct 0 ms 45120 KB Output is correct
16 Correct 0 ms 45120 KB Output is correct
17 Correct 1 ms 45120 KB Output is correct
18 Correct 0 ms 45120 KB Output is correct
19 Correct 0 ms 45120 KB Output is correct
20 Correct 0 ms 45120 KB Output is correct
21 Correct 5 ms 45120 KB Output is correct
22 Correct 7 ms 45120 KB Output is correct
23 Correct 7 ms 45120 KB Output is correct
24 Correct 6 ms 45120 KB Output is correct
25 Correct 0 ms 45120 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 45120 KB Output is correct
2 Correct 0 ms 45120 KB Output is correct
3 Correct 19 ms 45120 KB Output is correct
4 Correct 9 ms 45120 KB Output is correct
5 Correct 10 ms 45120 KB Output is correct
6 Correct 14 ms 45120 KB Output is correct
7 Correct 20 ms 45120 KB Output is correct
8 Correct 19 ms 45120 KB Output is correct
9 Correct 23 ms 45120 KB Output is correct
10 Correct 14 ms 45120 KB Output is correct
11 Correct 11 ms 45120 KB Output is correct
12 Correct 0 ms 45120 KB Output is correct
13 Correct 14 ms 45120 KB Output is correct
14 Correct 0 ms 45120 KB Output is correct
15 Correct 4 ms 45120 KB Output is correct
16 Correct 2 ms 45120 KB Output is correct
17 Correct 0 ms 45120 KB Output is correct
18 Correct 0 ms 45120 KB Output is correct
19 Correct 2 ms 45120 KB Output is correct
20 Correct 0 ms 45120 KB Output is correct
21 Correct 0 ms 45120 KB Output is correct
22 Correct 3 ms 45120 KB Output is correct
23 Correct 10 ms 45120 KB Output is correct
24 Correct 12 ms 45120 KB Output is correct
25 Correct 8 ms 45120 KB Output is correct
26 Correct 9 ms 45120 KB Output is correct
27 Correct 11 ms 45120 KB Output is correct
28 Correct 5 ms 45120 KB Output is correct
29 Correct 11 ms 45120 KB Output is correct
30 Correct 6 ms 45120 KB Output is correct
31 Correct 140 ms 45120 KB Output is correct
32 Correct 131 ms 45120 KB Output is correct
33 Correct 119 ms 45120 KB Output is correct
34 Correct 149 ms 45120 KB Output is correct
35 Correct 199 ms 45120 KB Output is correct
36 Correct 219 ms 45120 KB Output is correct
37 Correct 254 ms 45120 KB Output is correct
38 Correct 228 ms 45120 KB Output is correct
39 Correct 227 ms 45120 KB Output is correct
40 Correct 194 ms 45120 KB Output is correct