답안 #15054

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
15054 2015-07-11T07:47:15 Z myungwoo 빨간 직사각형 (kriii3_QQ) C++14
20 / 20
264 ms 10532 KB
#include <bits/stdc++.h>
using namespace std;

#define mp make_pair
typedef long long lld;
typedef pair<int, int> pii;

int N, M;
int H[3001];
char A[3001][3002];

int main()
{
	scanf("%d%d ", &N, &M);
	for (int i=1;i<=N;i++) scanf("%s", A[i]+1);
	lld ans = 0;
	for (int i=1;i<=N;i++){
		stack <pii> stk;
		stk.push(mp(-1, 0));
		lld val = 0;
		for (int j=1;j<=M;j++){
			H[j] = A[i][j] == 'R' ? H[j] + 1 : 0;
			while (!stk.empty() && stk.top().first >= H[j]){
				int h = stk.top().first, x2 = stk.top().second;
				stk.pop();
				int x1 = stk.top().second;
				val -= (x2-x1) * h;
			}
			val += H[j] * (j - stk.top().second);
			stk.push(mp(H[j], j));
			ans += val;
		}
	}
	printf("%lld\n", ans);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 10532 KB Output is correct
2 Correct 0 ms 10532 KB Output is correct
3 Correct 0 ms 10532 KB Output is correct
4 Correct 0 ms 10532 KB Output is correct
5 Correct 0 ms 10532 KB Output is correct
6 Correct 0 ms 10532 KB Output is correct
7 Correct 0 ms 10532 KB Output is correct
8 Correct 0 ms 10532 KB Output is correct
9 Correct 0 ms 10532 KB Output is correct
10 Correct 0 ms 10532 KB Output is correct
11 Correct 0 ms 10532 KB Output is correct
12 Correct 0 ms 10532 KB Output is correct
13 Correct 0 ms 10532 KB Output is correct
14 Correct 0 ms 10532 KB Output is correct
15 Correct 0 ms 10532 KB Output is correct
16 Correct 0 ms 10532 KB Output is correct
17 Correct 0 ms 10532 KB Output is correct
18 Correct 0 ms 10532 KB Output is correct
19 Correct 0 ms 10532 KB Output is correct
20 Correct 0 ms 10532 KB Output is correct
21 Correct 0 ms 10532 KB Output is correct
22 Correct 8 ms 10532 KB Output is correct
23 Correct 8 ms 10532 KB Output is correct
24 Correct 6 ms 10532 KB Output is correct
25 Correct 8 ms 10532 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 10532 KB Output is correct
2 Correct 0 ms 10532 KB Output is correct
3 Correct 16 ms 10532 KB Output is correct
4 Correct 26 ms 10532 KB Output is correct
5 Correct 22 ms 10532 KB Output is correct
6 Correct 21 ms 10532 KB Output is correct
7 Correct 26 ms 10532 KB Output is correct
8 Correct 23 ms 10532 KB Output is correct
9 Correct 25 ms 10532 KB Output is correct
10 Correct 24 ms 10532 KB Output is correct
11 Correct 25 ms 10532 KB Output is correct
12 Correct 5 ms 10532 KB Output is correct
13 Correct 21 ms 10532 KB Output is correct
14 Correct 5 ms 10532 KB Output is correct
15 Correct 4 ms 10532 KB Output is correct
16 Correct 5 ms 10532 KB Output is correct
17 Correct 4 ms 10532 KB Output is correct
18 Correct 5 ms 10532 KB Output is correct
19 Correct 5 ms 10532 KB Output is correct
20 Correct 5 ms 10532 KB Output is correct
21 Correct 8 ms 10532 KB Output is correct
22 Correct 8 ms 10532 KB Output is correct
23 Correct 17 ms 10532 KB Output is correct
24 Correct 18 ms 10532 KB Output is correct
25 Correct 16 ms 10532 KB Output is correct
26 Correct 11 ms 10532 KB Output is correct
27 Correct 13 ms 10532 KB Output is correct
28 Correct 13 ms 10532 KB Output is correct
29 Correct 14 ms 10532 KB Output is correct
30 Correct 13 ms 10532 KB Output is correct
31 Correct 223 ms 10532 KB Output is correct
32 Correct 171 ms 10532 KB Output is correct
33 Correct 189 ms 10532 KB Output is correct
34 Correct 214 ms 10532 KB Output is correct
35 Correct 212 ms 10532 KB Output is correct
36 Correct 263 ms 10532 KB Output is correct
37 Correct 226 ms 10532 KB Output is correct
38 Correct 264 ms 10532 KB Output is correct
39 Correct 189 ms 10532 KB Output is correct
40 Correct 214 ms 10532 KB Output is correct