The 3rd Series Problem Set


1. Diligent Tomas

Tomas is a student well known for his exceptional diligence. He decided to take as many lectures as possible. He studied the list of available lectures thoroughly but still he is not sure whether his schedule contains as many lectures as possible. He is worried about it very much - he lost 5 kg of weight during last week. So help him, please, before his weight becomes negative and he will fly away.

Task: Write a program which for a given list of available lectures writes the greatest number of lectures which Tomas's schedule can contain and example of such Tomas's schedule. Consider that Tomas can't be at the two different lectures at the same time and he can't come late for a lecture nor leave a lecture before its end. Do not forget to prove that your algorithm is correct.

Input: Each line of the input contains the specification of one lecture in a format like this one: Mo 07:20-09:45. Days of week are Mo Tu We Th Fr. There are no lectures on Saturday and Sunday.

Output:
Number of lectures in a schedule
List of lectures in a schedule

Example:


  Input:                       Output:
  Mo 07:20-09:45               2
  Tu 09:30-10:00               Mo 07:20-09:45
  Mo 09:00-10:35               Tu 09:30-10:00


2. Stevo's Visit in India

Stevo's journey led through Asia. Being there he found out he is very hungry. So he visited one shop in the village named Maharazajiad and wanted to buy a lot of food. Standing in a queue he observed a large inscription 1+1=10. He wondered what it meant. Then he got an idea. "They use some other number system in this shop!", he shouted and ran to the next shop. They used again another number system. In each shop there was an inscription with expression of the form A+B=C.

Stevo found corresponding page in his guide and he read that such expression determines the number system used in each particular shop. Stevo does not speak Hindi. When shopping he points to what he wants and he writes the amount on the paper. Thus he needs to know the number system used in given shop. Otherwise he can starve to death.

Task: Write a program which finds in which number systems holds given equality A + B = C.

Example:

Input: 1+1=10 Output: 2


3. The Tiribaki Rumfields

Enormous deposits of rum where recently discovered beneath the surface of Tiribaki Islands. Engineers determined locations for rum wells but the transportation of this liquid is not solved yet. Company which owns the rumfield decided to build one main pipeline through entire rumfield from east to west. Each well will be connected to this pipe by smaller connection pipeline. Now it is necessary to decide where to build the main pipeline to minimize the amount of material needed for connection pipelines. This problem should be considered soberly.

Task: Input consist of the number of rum wells N and the coordinates of all rum wells. Write a program which finds the y-coordinate of the main pipeline for which the sum of lengths of connection pipelines is as small as possible.

Example:


Input:                       Output:
5                            17
10 1
15 20
20 17
10 7
10 10

4. The Telephone Virus

Telephones of the latest generation are endangered by virus called Prepheeckunecz. Each Friday this virus changes the meaning of a infected phone's buttons so that for example after pressing number 1 the phone dials number 5. But this change is such that it is still possible to dial any number.

Fortunatelly each owner of a phone has his private directory of phone numbers. He presses various numbers and according to the person who answered he can find out the number actually dialed by phone. Thus he can explore new functions of buttons.

Task: Write a program which using as few telephone calls as possible finds out new functions of buttons. Program can use function dial(st:string):integer, which gets sequence of pressed buttons and returns the number of called person or zero if such person is not in the private directory. Private directory you have stored in array TZ[1..N_TZ], where TZ[i] is (correct) telephone number of the person i. If it is not possible to find new functions of all butons, program should write a message.

Example:
New functions of buttons 0,...,9: (3,5,0,9,1,8,4,6,7,2)
The directory contains numbers: [123,456,7890]
One possible sequence of dialing:

dial('350') returns 1
dial('918') returns 2
dial('4672') returns 3
dial('123') returns 0 (no one in directory has number 501)


5. SoDr and Meteorologists

In SoDr software house they have new customers --- meteorologists. Meteorologists need to know the range of directions in which the wind blew during last n minutes. They have a result of measuring of the direction of wind (in degrees) each minute.

Range of directions can be determined only as an arch. An arch is determined by two numbers a and b, which determine endpoints of this arch. Orientation of an arch is counterclockwise from a to b. For example (0,90) is one quarter of a circle and (90,0) three quarters.

Task: Input consist of two numbers n, k and n+k integers from interval [0,360), which are the results of measuring in minutes 1,2,...,n+k. Write a program which writes ranges of directions in which wind blew during last n minutes for minutes n,n+1,...,n+k. Assume k is at least 3.

Example:

Input: n=3, k=3, results: 0,30,60,90,120,150

Output: (0,60) (30,90) (60,120) (90,150)


(C) 1996, Organizers of the CSP