Author: | Roman Elizarov | |||
Input file: | code.in | Time limit: | 2 sec | |
Output file: | code.out | Memory limit: | 200 Mb |
Programmers are known to wage religious wars when issues of proper code formatting are discussed. When new team of programmers starts working on a project, it often brings slightly different code formatting style and wants to reformat old source code according to their own style. Moreover, inexperienced programmers often neglect the importance of good and consistent code style, thus complicating the work of their teammates and themselves. This situation creates thriving market for code formatting tools.
You are taking part in a proof-of-concept project for a new code formatting tool code named Salvation. This is only a pilot project aimed not for a practical usefulness, but to demonstrate your ability to parse and format code of a high-level language. Your task is to write code formatter for a language called TRIVIAL (The Rival Implementation-Agnostic Language). This language has trivial lexical and grammatical structures. It does not have any keywords and control structures, because all constructs of the language are represented as function calls and closures.
The lexical structure consists of identifiers, opening and closing parenthesis and curly braces, commas, and semi-colons. Identifiers consist only of digits '0'--'9' and Latin letters 'a'--'z', 'A'--'Z'. Lexical terms may be separated by whitespaces, leading and trailing whitespaces in the file are also allowed. Whitespace may consist of spaces, tab characters (ASCII code 9), and line separators (a pair of ASCII 13, 10).
The structure of the valid trivial program is derived from the following productions:
- Program ::= Block
- Block ::= '{' Statements '}'
- Statements ::= Statement | Statement Statements
- Statement ::= Expression ';'
- Expression ::= identifier ['(' Arguments ')'] [Block]
- Arguments ::= Expression | Expression ',' Arguments
Properly formatted trivial program additionally conforms to the following rules:
See sample output section for an example of properly formatted trivial program.
No. | Input file (code.in ) |
Output file (code.out ) |
---|---|---|
1 |
|
|
Author: | Andrew Stankevich (text), Elena Kryuchkova (original idea) | |||
Input file: | farmer.in | Time limit: | 2 sec | |
Output file: | farmer.out | Memory limit: | 200 Mb |
It is rumored that the planet Earth is often visited by Unidentified Flying Objects (UFOs). Sometimes UFOs land and leave burned out regions. Observations show that these regions have the form of circles.
Recently farmer Bill has found such circles on his nice rectangular wheat field. Bill likes all mysterious things very much, so he has decided to keep these circles on the field. However, although being an ufolog, first of all Bill is the farmer, so he needs to harvest his wheat. Therefore he has decided to keep some regions containing circles intact, and harvest the rest of the field.
All regions that Bill keeps unharvested must be rectangles that neither touch nor overlap each other. The sides of the rectangles must be parallel to the sides of the field. All circles left by UFOs must be inside these regions. The total area of the regions must be minimal possible, so that Bill could harvest the maximal possible part of his field.
Now Bill wants to know the total area of the field that he will be able to harvest. Help him!
The first line of the input file contains two integer numbers x and y — the dimensions of Bill's field. Let Bill's field be positioned on the plane in such a way that its corners are located in points with coordinates (0, 0), (x, 0), (x, y) and (0, y).
The second line of the input file contains N — the number of circles left by UFOs on Bill's field. Next N lines describe circles: each line contains three positive integer numbers xi, yi and ri — coordinates of the center and radius of the circle. Circles may touch, overlap or contain each other. All circles are completely located within the field bounds.
No. | Input file (farmer.in ) |
Output file (farmer.out ) |
---|---|---|
1 |
|
|
2 |
|
|