-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathCTGAME.cpp
More file actions
40 lines (40 loc) · 1.28 KB
/
Copy pathCTGAME.cpp
File metadata and controls
40 lines (40 loc) · 1.28 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
// Ivan Carvalho
// Solution to https://www.spoj.com/problems/CTGAME/
#include <algorithm>
#include <cstdio>
using namespace std;
int matriz[1001][1001], resp, TC;
int main() {
scanf("%d", &TC);
while (TC--) {
int n, m;
resp = 0;
scanf("%d %d", &n, &m);
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
char c;
scanf(" %c", &c);
matriz[i][j] = matriz[i][j - 1] + (c == 'R');
}
}
for (int coluna_ini = 1; coluna_ini <= m; coluna_ini++) {
for (int coluna_fim = m; coluna_fim >= coluna_ini; coluna_fim--) {
if ((coluna_fim - coluna_ini + 1) * n <= resp) continue;
int best = 0, atual = 0;
for (int linha = 1; linha <= n; linha++) {
if (matriz[linha][coluna_fim] -
matriz[linha][coluna_ini - 1] ==
0) {
atual++;
best = max(best, atual);
} else {
atual = 0;
}
}
resp = max(resp, best * (coluna_fim - coluna_ini + 1));
}
}
printf("%d\n", 3 * resp);
}
return 0;
}