Magyar Information Contest Journal Articles

# Problem I. 373. (April 2015)

I. 373. An effective way to format a text is to use styles: various attributes of text blocks can be set simultaneously with the corresponding styles, instead of setting the attributes one by one. In most applications, styles are not separate elements, but they can be given a tree structure. A particular attribute of a text block is determined by a value set locally. If a value is not given locally, then that attribute is determined by the one occurring in the corresponding style, or in the closest style above the actual style in the tree structure.

In this task we work with a simplified model of the above: text blocks are paragraphs, and attributes are positive integers. Create your program i373 to perform the following: for a given description of styles, it should produce another equivalent description, as compact as possible, then list the actual attributes for each text block.

The input file (Bemenet'' in the example) consists of two parts. The first line of the first part is the number of the styles $\displaystyle s$, then each of the following $\displaystyle s$ lines describes a style. The first character (an uppercase letter of the English alphabet) is the style name, the next one is the style name just above the actual style in the tree structure (for the tree root, these first two characters are identical), then each attribute-value pair is given in the form of a lowercase English letter-positive integer''. Values are separated by exactly one space character. The second part of the input file first contains the number of paragraphs $\displaystyle b$ ($\displaystyle b\le 500$) in the text. Then each of the following $\displaystyle b$ lines describes a paragraph. The first character is the name of the applied style, then the locally valid attribute--value pairs are listed in a format similar to the one specified in the first part of the file.

The structure of the output file (Kimenet'' in the example) is the same as the structure of the input file. The first part of the file contains the simplified style descriptions. In a simplified style description, a particular attribute should not appear if it does not modify the same attribute set in the styles above the actual one in the tree structure. The second part of the file contains a complete description of the actual attributes for each paragraph.

The first and second command line arguments to your program are the name of the input and output files, respectively.

The source code of your program (i373.pas, i373.cpp, ...) with a short documentation (i373.txt, i373.pdf, ...) - containing a brief description of your solution and specifying the developer environment to compile the source code - should be submitted as i373.zip.

(10 pont)

Deadline expired on May 11, 2015.

### Statistics:

 9 students sent a solution. 10 points: Mócsy Miklós. 7 points: 1 student. 6 points: 2 students. 5 points: 1 student. 4 points: 1 student. 2 points: 2 students. 0 point: 1 student.

 Our web pages are supported by: Morgan Stanley