Mathematical and Physical Journal
for High Schools
Issued by the MATFUND Foundation
Already signed up?
New to KöMaL?
I want the old design back!!! :-)

Problem S. 23. (January 2007)

S. 23. The table below shows file names and locations of their fragments on a hard drive:

1. weather.txt 160 0
2. --- 17 5
3. tale.doc 180 0
4. --- 20 2
5. --- 5 10
6. tale.doc 28 3
7. snow 128 0
8. santa.jpg 560 0
9. snow 47 7
10. --- 633 0

Rows of the table (at most 100000) represent consecutive areas of the hard drive (possibly of different size). Each row of the table contains the following information: either the name of the file or three dashes (the first numbers in each row of the example are there for easier readability only, so they are not part of the file names).

The file name consists of small letters of the English alphabet, and possibly a dot. The three dashes represent free space on the drive. After the file name or the dashes a space character follows, then the size of the file fragment or the free space (an integer between 1 and 100000). Then again a space character stands, finally an integer representing the location of the next fragment of the file in the table (being a positive integer, or 0, if this is the end of the file or the free space).

Write your program that sorts alphabetically the file names and the free space on the drive. The file name should be given first, then its total size, finally the starting and ending segments of the fragments of the file in the correct order separated by a dash. (All of these pieces of information are separated by space characters.) So in our example the output should be

snow 175 1099-1145 411-538
weather.txt 160 1-160
tale.doc 208 383-410 178-357
santa.jpg 560 539-1098
--- free space 675 358-377 161-177 378-382 1046-1078

Your program reads names of the input and output files from the command line, for example, s23.exe input.txt output.txt. The input file has a similar structure as in the example (but without the leading ordinal numbers). Your program will be tested thoroughly (with several thousand files on the virtual hard drive) and is expected to yield the final result within a few minutes.

Your source code (S23.pas, S23.cpp, ...) and a short documentation (S23.txt, S23.pdf, ...) should be submitted.

(10 pont)

Deadline expired on February 15, 2007.

Sorry, the solution is available only in Hungarian. Google translation

A megoldások értékelését hat szöveges állománnyal végeztük. Ezeket és a kapott helyes kimenetet az alábbi tömörített állomány tartalmazza:

Mintaként Kiss Dániel Miklós budapesti versenyző C++ programját (s23.cpp) és Györök Péter kaposvári versenyző Pascal/Delphi munkáját (s23.dpr) adjuk közre.


8 students sent a solution.
10 points:Csernai Kornél, Györök Péter, Kezes Balázs, Kiss Dániel Miklós, Sztupovszki Szabolcs.
9 points:Ócsvári Ádám.
6 points:1 student.
3 points:1 student.

Problems in Information Technology of KöMaL, January 2007