
| Contests | Virtual Contests | Problems | Submit | Runs Status | Rank List | Forum |
Figure 2 below shows two possible solutions, the second of which is preferable since it uses two robots rather than three.
Your task is to create a program that will determine the minimum number of robots needed to pick up all the garbage from a field.
An input file consists of one or more field maps followed by a line containing -1 -1 to signal the end of the input data. A field map consists of one or more lines, each containing one garbage location, followed by a line containing 0 0 to signal the end of the map. Each garbage location consists of two integers, the row and column, separated by a single space. The rows and columns are numbered as shown in Figure 1. The garbage locations will be given in row-major order. No single field map will have more than 24 rows and 24 columns. The sample input below shows an input file with two field maps. The first is the field map from Figure 1.
The output will consist of a single line for each field map containing the minimum number of robots needed to clean the corresponding field.
| Sample Input | Sample Output |
|
1 2 1 4 2 4 2 6 4 4 4 7 6 6 0 0 1 1 2 2 4 4 0 0 -1 -1 |
2 1 |