2001 LSU Computer Science High School Programming Contest

Sponsored by Texas Instruments

Novice and Veteran - Problem 1

Mud Wars

Description: One little-known and less cared for fact about our favorite Doctor is that he once worked for the Louisiana Highway Safety Commission. In his brief stint at the LHSC, he developed a decidedly unique solution to the ubiquitous "pothole" problem prevalent on many Louisiana roads.

Dr. Brownian determined that since the inordinate amount of patching done on the highway system seems to have had little to no effect, the cure must be for the symptoms instead of the cause. Because of this, he had the bright idea of having State employees drive around in flat-bed trucks on the "problem" roads and then having them throw water balloons at the muddied vehicles on the road.

Like pretty much all of Dr. Brownian's exploits, the so-called Mud Wars effort turned into a troublesome nightmare. Incidents involving rogue water-ballooning, out-of-control mud-splattering, and the occasional petunia caused the Highway Safety Commission to close the project down practically before it started.

Many years later, one of the good Doctor's graduate students found out about his exploits in the wide world of vehicular safety, and decided to implement a Mud Wars simulator. As the graduate student was a member of the Baton Rouge chapter of the Internatonal Game Developer's Association, he decided to add it as a hidden mini-game inside of the mysterious Project Y. Here is a portion of the brainstorming documents that came out of one of the meetings:

Project Y: Mud Wars Scoring Scheme

The graphics and sounds in the Mud Wars minigame have all been finalized -- the Ferd Perfect looks, well, perfect, but a scoring system has yet to be implemented. The tentative methodology behind scoring Mud Wars is as follows:

  1. The vehicle can hit a mudhole with any of the four wheels of the Perfect. When a mudhole is hit, a certain amount of mud is splashed on both sides adjacent to that wheel. For example, if the Perfect hits a mud-filled mudhole with the rear left wheel, mud will splatter on both the left side of the vehicle and the back of the vehicle. The splatter is equal on both sides: if 20 points of mud is in the mudhole, then 10 points of mud get on the two sides. Any fractional amount of mud is disregarded entirely, as it slides harmlessly off.
  2. The vehicle can also be hit on any of the four sides by a water balloon. The balloon contains a certain amount of water and 'cleanser', which removes some number of mud points. A balloon can hit on the front, back, or either side of the Perfect. All of the points of the balloon are subtracted from the points of mud on the side that it hits.
  3. There are also occasional showers, which last for a certain number of in-game minutes. For each minute of a shower, seven points of mud are subtracted from the front of the vehicle, five points of mud are subtracted from both the left and right sides, and two points of mud are subtracted from the back.
  4. At no time may the amount of mud on a side be less than zero (you can't get cleaner than clean), or greater than 100. The front side of the vehicle may have, at maximum, 35 points of mud. If any side other than the front of the vehicle gets mud added to it that brings it over 100 points, they are disregarded (only so much mud will stick to a Ferd Perfect before it starts sliding off). However, if the front of the vehicle ever gets mud added to it that brings the total above 35, the Perfect overheats and stalls in the middle of the road, ending the game.
  5. If the player successfully navigates the entire course, they have successfully beaten Mud Wars. Unlike most games, the object in Mud Wars is to get the lowest score possible. A perfect score of zero means that the player has managed to finish the course with no mud on the Ferd Perfect (very difficult to do). If the player does not have a perfect score, they must go to a self-service car wash and clean' the Perfect. As each point of mud washes off, the score goes up by $1.00 (with a $2.00 as the minimum non-perfect score). When the washing ends, the player may enter their name in the hall of fame (if they were clean enough).

Let's see how this works.

Input: The data file format will be as follows:

   <number of data sets>
   <number of actions in the first set>
   <action> 
   <value>
   <action>
   <value>
   <action> 
   <value>
   . . .
   <last action of first set>
   <If there is a second set, number of actions in the second set>
   <action> 
   <value>
   <action> 
   <value>
   <action> 
   <value>
   . . .

where the <action> <value> pairs work as following:
<action> <value>
1 the Perfect hits a mudhole with its back left tire, and <value>/2 mud points are splashed onto the back and left sides of the car
2 a water balloon hits the back of the Perfect and removes <value> number of mud points
3 the Perfect hits a mudhole with its back right tire, and <value>/2 mud points are splashed onto the back and right sides of the car
4 a water balloon hits the left side of the Perfect and removes <value> number of mud points
5 the Perfect drives through a shower for <value> minutes. The front of the vehicle loses <value> * 7 mud points, the left and right sides lose <value> * 5 mud points, and the back of the Perfect loses <value> * 2 mud points
6 a water balloon hits the right side of the Perfect and removes <value> number of mud points
7 the Perfect hits a mudhole with its front left tire, and <value>/2 mud points are splashed onto the front and left sides of the car
8 a water balloon hits the front of the Perfect and removes <value> number of mud points
9 the Perfect hits a mudhole with its front right tire, and <value>/2 mud points are splashed onto the front and right sides of the car

Output: The output of the program for each play is either a number signifying the cost of the car wash at the end:

15

or the phrase

GAME OVER, MAN

if the car overheated and stalled.

Sample Input:

1		number of data sets
10		number of actions in this set
7 		action
12 		value
9		action
18 		value
1		action
8 		value
3		action
9 		value
8		action
2		value
4 		action
4		value
5 		action
2		value
6 		action
2		value
2 		action
5		value
1 		action
5		value

Note: The items in italics are here to help you understand the data. Your real input will only have the numbers.

Sample Output:

5

Explanation: The data says that one data set is present.
The second line says that 10 actions are going to happen.
Action Value Explanation Front Right Back Left
7 12 6 points of mud is splattered on the front and on the left side 6 0 0 6
9 18 9 points of mud are splattered on the front and right side 15 9 0 6
1 8 4 points of mud are splattered on the back and the left side 15 9 4 10
3 9 4 points of mud are splattered on the back and the right side 15 13 8 10
8 2 water balloon hits front removing 2 points of mud 13 13 8 10
4 4 water balloon hits left side removing 4 points of mud 13 13 8 6
5 2 rains for 2 minutes, front loses 14 points, sides lose 10 points and back loses 4 points 0 3 4 0
6 2 water balloon hits right side removing 2 points of mud 0 1 4 0
2 5 water balloon hits back removing 5 points of mud 0 1 0 0
1 5 2 points of mud are splattered on the back and the right side 0 1 2 2


Return to Problem Index



 

The statements and opinions included in these pages are those of 2001 LSU Computer Science High School Programming Contest only. Any statements and opinions included in these pages are not those of Louisiana State University or the LSU Board of Supervisors.
© 2000,2001 Isaac Traxler
Last modified: Friday, 01 July, 2011 16:24:51