In a future mission to Mars, a pod containing a number of Mars exploration vehicles (MEVs), will be landing on the surface of Mars. All the MEVs will be released at the pod's landing site, from which they will move towards a transmitter that has landed a short distance away. While the vehicles move towards the transmitter, they are required to gather rock samples. A rock may only be sampled once, by the first MEV to visit the rock. After that, the rock may not be sampled again, but other MEVs may pass the same position. The vehicles cannot move onto rough terrain. The design of the vehicle is such that it can only move south or east in a path that follows the grid pattern from the pod to the transmitter. More than one MEV may occupy the same position at the same time.
0000000000
0000011000
0001020000
1101200001
0100201100
0101001100
0120000100
0000000000
Warning: If a MEV gets stuck, its samples are lost and the sites sampled cannot be resampled.
Task
Calculate the individual movement of the vehicles to maximise the number of rock samples collected and the number of MEVs that reach the transmitter, using the vehicles that landed with the pod.
Input Specification
The surface of the planet between the pod and the transmitter is represented by a grid with the pod position always at position and the transmitter located at . The definitions of the different types of terrain are as follows:
- Clear terrain:
0
- Rough terrain:
1
- Rock sample:
2
The input consists of:
and are the size of the grid, and is an integer less than , representing the number of vehicles released by the pod. lines each represent a row in the surface representation. and will not exceed .
Sample Input
2
10
8
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 1 1 0 0 0
0 0 0 1 0 2 0 0 0 0
1 1 0 1 2 0 0 0 0 1
0 1 0 0 2 0 1 1 0 0
0 1 0 1 0 0 1 1 0 0
0 1 2 0 0 0 0 1 0 0
0 0 0 0 0 0 0 0 0 0
Output Specification
A sequence of lines representing the movements of the MEVs towards the transmitter. Each line contains a vehicle number and a digit 0 or 1, where 0 is a move South and 1 a move East.
Sample Output
1 1
1 0
2 1
2 0
1 1
1 1
2 0
2 1
2 0
2 0
2 0
2 0
1 1
1 0
1 0
1 0
1 0
1 0
1 0
2 0
2 1
1 1
1 1
1 1
1 1
1 1
2 1
2 1
2 1
2 1
2 1
2 1
Scoring
Your solution will be deemed correct if the number of samples collected and taken to the transmitter + number of MEVs reaching the transmitter - number of MEVs not reaching the transmitter is equal to the maximum possible score. Note that an illegal move invalidates a solution set. An illegal move occurs when a MEV is moved over rough terrain, or outside the grid.
Comments
Get this dumb ass question down the problem list. It has a flaw that embarrasses even me: Try this, for those who think they had solved this retarded mess:
For those who can get 14 samples, you can get 16 samples in total by doing:
That's the first one.
second one:
...so what exactly is the flaw? Stating an incorrect answer and a correct answer for a test case doesn't really show anything.
A lot of the algorithms (at least 1) that AC-ed would output 14 as the answer for this test case, but the correct answer is 16.