City game
Time limit:3000 Ms
Memory limit:0 KB
64bit Io format:% LLD & % llusubmit status
Description
Bob is a strategy game programming specialist. in his new city building game the gaming environment is as follows: a city is built up by areas, in which there are streets, trees, factories and buildings. there is still some space in the area that is unoccupied. the strategic task of his game is to win as much rent money from these free spaces. to win rent money you must erect buildings, that can on Ly be rectangular, as long and wide as you can. Bob is trying to find a way to build the biggest possible building in each area. But he comes has SS some problems? He is not allowed to destroy already existing buildings, trees, factories and streets in the area he is building in.
Each area has its width and length. The area is divided into a grid of equal square units. The rent paid for each unit on which you're building stands is 3 $.
Your task is to help Bob solve this problem. the whole city is divided into k areas. each one of the areas is rectangular and has a different grid size with its own length m and width n. the existing occupied units are marked with the symbol R. the unoccupied units are marked with the symbol F.
Input
The first line of the input file contains an integer k? Determining the number of datasets. next lines contain the area descriptions. one description is defined in the following way: the first line contains two integers-area length m <= 1000 and width n <= 1000, separated by a blank space. the next M lines contain N symbols that mark the reserved or free grid units, separated by a blank space. the symbols used are:
R? Reserved Unit
F? Free Unit
In the end of each area description There is a separating line.
Output
For each data set in the input file print on a separate line, on the standard output, the integer that represents the profit obtained by erecting the largest building in the Area encoded by the data set.
Sample Input
25 6R F F F F FF F F F F FR R R F F FF F F F F FF F F F F F5 5R R R R RR R R R RR R R R RR R R R RR R R R R
Sample output
450
Algorithm parsing:
Scan Line simulation!
R f 0 1 2 3 4 5f f 1 2 3 4 5 6R R f = "0 0 0 1 2 3f f 1 2 3 4 5 6f f 1 2 3 4 5 6
R is 0, and continuous F is assigned 1 ++; (this is useful. In fact, we can judge the continuous width)
# Include <stdio. h> # include <string. h> int map [1001] [1001]; int main () {int t; scanf ("% d", & T); int I, j, k; int N, m; char ch; while (t --) {scanf ("% d % * C", & N, & M); memset (MAP, 0, sizeof (0); // each time you have to initialize for (I = 1; I <= N; I ++) {for (j = 1; j <= m; j ++) {CH = getchar (); While (Ch! = 'F' & Ch! = 'R') {CH = getchar ();} If (CH = 'F ') {map [I] [J] = map [I] [J-1] + 1;} else {map [I] [J] = 0 ;}}} // when creating a map, pay attention to the processing of characters and spaces, and then convert them into numbers to be saved in map // The storage method should be int min; int area = 0; // The initial area is 0int high; // The height defined for (I = 1; I <= N; I ++) {for (j = 1; j <= m; j ++) {If (Map [I] [J]! = 0) // access data> 0: (f) {min = map [I] [J]; If (area <map [I] [J]) {area = map [I] [J];} high = 1; // initial height self for (k = I-1; k> = 1; k --) {If (Map [k] [J] = 0) break; else {high ++; // increase the height of IF (Map [k] [J] <min) {min = map [k] [J];} If (area