forked from shunr/competitive-programming
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathccoprep16q1.cpp
More file actions
77 lines (68 loc) · 1.65 KB
/
ccoprep16q1.cpp
File metadata and controls
77 lines (68 loc) · 1.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#include <bits/stdc++.h>
char grid[1000][1000];
char histo[1000][1000];
int main() {
int n;
scanf("%i", &n);
for (int _ = 0; _ < n; _++) {
int l, w;
int best = 0;
scanf("%i %i", &l, &w);
for (int i = 0; i < l; i++) {
for (int j = 0; j < w; j++) {
int x;
scanf(" %c", &x);
if (x == 'R') {
histo[j][i] = 0;
} else {
if (i > 0) {
histo[j][i] = histo[j][i-1] + 1;
} else {
histo[j][i] = 1;
}
}
}
}
for (int i = 0; i < l; i++) {
for (int j = 0; j < w; j++) {
if (histo[j][i] == 0) {
grid[j][i] = 0;
} else {
if (j > 0 && histo[j-1][i] >= histo[j][i]) {
grid[j][i] = grid[j-1][i] + 1;
} else {
grid[j][i] = 1;
}
}
int kek = grid[j][i] * histo[j][i];
if (kek > best) {
best = kek;
}
}
}
for (int i = 0; i < l; i++) {
for (int j = w-1; j >= 0; j--) {
if (histo[j][i] == 0) {
grid[j][i] = 0;
} else {
if (j < w-1 && histo[j+1][i] >= histo[j][i]) {
grid[j][i] = grid[j+1][i] + 1;
} else {
grid[j][i] = 1;
}
}
int kek = grid[j][i] * histo[j][i];
if (kek > best) {
best = kek;
}
}
}
/*for (int i = 0; i < l; i++) {
for (int j = w-1; j >= 0; j--) {
printf("%i ", grid[j][i]);
}
printf("\n");
}*/
printf("%i\n", best * 3);
}
}