Problem I. 150. (January 2007)
I. 150. There are N cars (a few hundred) waiting at a traffic lamp. The lamp shows green for 45 seconds, then red for 15 seconds. Make a program to graphically simulate cars crossing the intersection. Cars are depicted as rectangles: the shorter side (width) has a constant length, while the longer side (length) has a random length. The acceleration is inversely proportional with the length of the car. The shortest car has length of 2 meters and accelerates to 100 km/h in 4 seconds, while the longest one has length of 20 meters and accelerates to this speed in one minute. The first car at the traffic lamp starts immediately when the green signal appears, with its maximal acceleration, until it reaches the maximal allowed speed (50 km/h). The next car starts after 1 second and accelerates according to its preset parameters (but its acceleration can not exceed that of the first car). If a car approaches another car within 20 meters, it immediately brakes and stops exactly 2 meters behind the first car. If the traffic lamp changes to red when the car is already within stopping distance (20 meters), then the vehicle proceeds further and crosses the intersection. Otherwise, if the car has enough time, then it brakes immediately and stops exactly at the lamp. You should update the position of the cars in every second. A car disappears when it has crossed the intersection, while the other cars behind it appear gradually until the queue of cars disappears. (The random length of this queue is determined in advance.) Cars in front of the traffic lamp should fill approximately 80% of the screen, while cars that have already crossed the intersection should occupy the remaining 20%.
The source code with appropriate documentation should be submitted.
(10 pont)
Deadline expired on February 15, 2007.
Sorry, the solution is available only in Hungarian. Google translation
Nagyon sok szép megoldás érkezett. Ezek közül ezúttal Polgárfi Bálint 12. a. /Kapuvár Felsőbüki Nagy Pál Gimnázium/ megoldását szeretném közzé tenni. (const ido=250; helyett gyorsabb gépeken 25000at érdemes beállítani)
I150.PAS
Statistics:
15 students sent a solution.  
10 points:  Balambér Dávid, Czigler András, Danka Miklós András, Gilián Zoltán, Gombos Gergely, Györök Péter, Polgárfi Bálint, Ridinger Tamás, Szoldatics András, Véges Márton, Vincze János. 
8 points:  2 students. 
7 points:  2 students. 
