IOI '97 - Cape Town, South Africa
You are a cartographer's assistant, and have been given the difficult task of writing the names of cities onto a new map.
The map is a grid of

Figure 1: a city with the four possible positions of its label
The placement of labels must satisfy the following constraints:
- A city's label must appear in one of four positions with respect to the city as illustrated in figure
. - Labels must not overlap each other.
- Labels must not overlap cities.
- Labels must completely fit on the map.
Each label contains all the letters in a city name plus a single space. For each city name the width and height of its letters will be given; the single space has the same size.
0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | ||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | _ | C | e | r | e | s | ||||||||||
1 | O | P | a | a | r | l | _ | |||||||||
2 | ||||||||||||||||
3 | O | O | ||||||||||||||
4 | L | a | n | g | a | _ | ||||||||||
_ represents a spaceO represents the position of a city |
The leftmost column of the map has horizontal index 0 and the top row
has vertical index
Your program must read the locations of the cities on the map, followed by their letter dimensions and names. The program must then place as many labels on the map as it can without violating the constraints above, and output the locations of the labels that have been placed.
Input Specification
The input starts with a line containing an integer
- the city's horizontal index
, - the city's vertical index
, - the integer width
for each character of the city name, - the integer height
for each character of the city name, and - the city name itself, which consists only of uppercase and lowercase characters from
A
toZ
.
City names are all single words. The number of cities is at most
Output Specification
Your program must output -1 -1
for that city. These lines should be printed in the same order as the
cities are given in the input.
Sample Input
Input | Explanation |
---|---|
Copy
|
Copy
|
Sample Output
Output | Explanation |
---|---|
Copy
|
Copy
|
Scoring
For each test case:
- Your score will be given as the percentage of city names placed by your program with respect to an excellent solution of the IOI organisers, rounded to the nearest integer percent.
- The minimum score is
and the maximum score is . - If any label violates the constraints, your program will score
. - If labels do not match the cities given, your program will score
.
Comments