# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
15045 |
2015-07-11T06:55:43 Z |
hongjun7 |
빨간 직사각형 (kriii3_QQ) |
C++ |
|
363 ms |
45696 KB |
#include <cstdio>
#include <stack>
#include <vector>
#include <algorithm>
using namespace std;
int n, m;
int nu[3005][3005];
char S[3005][3005];
long long d[3005];
int main() {
scanf("%d%d", &n, &m);
for (int i = 1; i <= n; i++) scanf("%s", S[i] + 1);
for (int i = 1; i <= n; i++) {
for (int j = m; j >= 1; j--) {
nu[i][j] = S[i][j] == 'B' ? 0 : nu[i][j+1] + 1;
}
}
long long res = 0;
for (int i = 1; i <= m; i++) {
stack < pair <int, int> > s;
for (int j = 1; j <= n; j++) {
while (s.size() > 0 && s.top().first >= nu[j][i]) s.pop();
long long v = 0;
if (s.size() > 0) {
v = d[s.top().second];
d[j] = v + (long long)(j - s.top().second)*(nu[j][i]);
}
else
d[j] = (long long)(nu[j][i]) * (j);
s.push(make_pair(nu[j][i], j));
res += d[j];
}
}
printf("%lld", res);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
45696 KB |
Output is correct |
2 |
Correct |
0 ms |
45696 KB |
Output is correct |
3 |
Correct |
0 ms |
45696 KB |
Output is correct |
4 |
Correct |
0 ms |
45696 KB |
Output is correct |
5 |
Correct |
0 ms |
45696 KB |
Output is correct |
6 |
Correct |
0 ms |
45696 KB |
Output is correct |
7 |
Correct |
0 ms |
45696 KB |
Output is correct |
8 |
Correct |
0 ms |
45696 KB |
Output is correct |
9 |
Correct |
0 ms |
45696 KB |
Output is correct |
10 |
Correct |
0 ms |
45696 KB |
Output is correct |
11 |
Correct |
0 ms |
45696 KB |
Output is correct |
12 |
Correct |
0 ms |
45696 KB |
Output is correct |
13 |
Correct |
0 ms |
45696 KB |
Output is correct |
14 |
Correct |
0 ms |
45696 KB |
Output is correct |
15 |
Correct |
0 ms |
45696 KB |
Output is correct |
16 |
Correct |
0 ms |
45696 KB |
Output is correct |
17 |
Correct |
0 ms |
45696 KB |
Output is correct |
18 |
Correct |
0 ms |
45696 KB |
Output is correct |
19 |
Correct |
0 ms |
45696 KB |
Output is correct |
20 |
Correct |
0 ms |
45696 KB |
Output is correct |
21 |
Correct |
4 ms |
45696 KB |
Output is correct |
22 |
Correct |
10 ms |
45696 KB |
Output is correct |
23 |
Correct |
5 ms |
45696 KB |
Output is correct |
24 |
Correct |
4 ms |
45696 KB |
Output is correct |
25 |
Correct |
10 ms |
45696 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
45696 KB |
Output is correct |
2 |
Correct |
6 ms |
45696 KB |
Output is correct |
3 |
Correct |
31 ms |
45696 KB |
Output is correct |
4 |
Correct |
27 ms |
45696 KB |
Output is correct |
5 |
Correct |
25 ms |
45696 KB |
Output is correct |
6 |
Correct |
28 ms |
45696 KB |
Output is correct |
7 |
Correct |
27 ms |
45696 KB |
Output is correct |
8 |
Correct |
26 ms |
45696 KB |
Output is correct |
9 |
Correct |
32 ms |
45696 KB |
Output is correct |
10 |
Correct |
24 ms |
45696 KB |
Output is correct |
11 |
Correct |
30 ms |
45696 KB |
Output is correct |
12 |
Correct |
0 ms |
45696 KB |
Output is correct |
13 |
Correct |
34 ms |
45696 KB |
Output is correct |
14 |
Correct |
6 ms |
45696 KB |
Output is correct |
15 |
Correct |
6 ms |
45696 KB |
Output is correct |
16 |
Correct |
6 ms |
45696 KB |
Output is correct |
17 |
Correct |
0 ms |
45696 KB |
Output is correct |
18 |
Correct |
6 ms |
45696 KB |
Output is correct |
19 |
Correct |
3 ms |
45696 KB |
Output is correct |
20 |
Correct |
0 ms |
45696 KB |
Output is correct |
21 |
Correct |
4 ms |
45696 KB |
Output is correct |
22 |
Correct |
6 ms |
45696 KB |
Output is correct |
23 |
Correct |
16 ms |
45696 KB |
Output is correct |
24 |
Correct |
22 ms |
45696 KB |
Output is correct |
25 |
Correct |
17 ms |
45696 KB |
Output is correct |
26 |
Correct |
9 ms |
45696 KB |
Output is correct |
27 |
Correct |
20 ms |
45696 KB |
Output is correct |
28 |
Correct |
12 ms |
45696 KB |
Output is correct |
29 |
Correct |
15 ms |
45696 KB |
Output is correct |
30 |
Correct |
10 ms |
45696 KB |
Output is correct |
31 |
Correct |
262 ms |
45696 KB |
Output is correct |
32 |
Correct |
289 ms |
45696 KB |
Output is correct |
33 |
Correct |
294 ms |
45696 KB |
Output is correct |
34 |
Correct |
274 ms |
45696 KB |
Output is correct |
35 |
Correct |
251 ms |
45696 KB |
Output is correct |
36 |
Correct |
317 ms |
45696 KB |
Output is correct |
37 |
Correct |
353 ms |
45696 KB |
Output is correct |
38 |
Correct |
363 ms |
45696 KB |
Output is correct |
39 |
Correct |
310 ms |
45696 KB |
Output is correct |
40 |
Correct |
283 ms |
45696 KB |
Output is correct |