Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register
Language:
Acid Text
Time Limit: 2000MSMemory Limit: 65536K
Total Submissions: 951Accepted: 235

Description

Background
A couple of months ago the web standards project (WaSP) has come up with a test for modern browsers and their CSS implementation called acid2. This test ensures that all the browsers have similar results when it comes to parsing and displaying cascaded style sheet files (CSS) for HTML. Since you want to beat all the other text-based browsers on standard compliance you directly start implementing the CSS capabilities into your favorite text-browser Lynks.
Problem
Your text-browser will be given a set of graphic files and a simplified css-style-sheet. A graphic is defined by a name, height, width and a 2-dimensional array of characters. All characters are to be printed except for the character '.' which denotes a transparent pixel. Here is an example picture:

owl.png 5 7
.-----.
|O...O|
|..v..|
|.<_>.|
.-----.

Given the style-sheet your task is it to produce the graphical result that the browser is supposed to display. A CSS-file is made up from a number of entries where each entry looks like this:
#<id> {

pos-x : <x> px ;
pos-y : <y> px ;
position : <relative = <id of graphic>|absolute> ;
file : <filename> ;
layer : <layer-number> ;
}

The following rules hold for the CSS-entries:
Lines Each CSS-entry will be given on exactly 7 lines as in the input above.
Ordering Each CSS-entry will contain exactly the 5 attributes pos-x, pos-y, position, file and layer, in this order, each attribute on a separate line.
Whitespace There may be zero or more white-spaces (spaces and tabs) at the beginning of lines, at the end of lines or everywhere where the sample above has a space.
Here are the rules for composing the picture:
Background The background is assumed to be black (i.e. just spaces).
Positioning The top left corner of the viewing device is assumed to be x : 0, y : 0. Absolute positioning always is based on this top-left corner. Relative positioning information is always based on the topleft pixel of another graphic. There will not be any circular references between CSS elements. All resulting positions will be zero or greater in x and y.
Layering Graphics with a higher layer number are to be printed after graphics with a lower layer number. Graphics with the same layer number are to be printed in the order they appear in the CSS.

Input

The first line of the input is the number of scenarios that will follow. For each scenario the following information is given: The first line contains the number of files to follow (at least one, at most 100), each of which is given by a space separated triple of a filename f, a height h, a width w (1 <= w, h <= 100) and then h lines, each with exactly w characters. Following the file definition is a single line with a number m (at least one, at most 500), which is followed by a CSS file of m entries.
You can assume the resulting picture to be at most 1000 x 1000 characters large. All coordinates in CSS entries will be given as integers with an absolute value less than 1000000. All filenames and identifiers are made up from alphanumeric characters and dots only. No two files have the same name and no two identifiers are equal. The layer attribute will be at least 0 and at most 1000000.

Output

The output for every scenario begins with a line containing "Scenario #i:", where i is the number of the scenario starting at 1. For each scenario print the resulting picture from overlaying all the given graphics following the instructions in the CSS file. Your result for each scenario should be rectangular as small as possible. However, transparent pixels always belong to the resulting picture, even if they are located directly at the border. The top-left corner of the result should always contain position (0, 0). All empty areas should be padded with spaces. Terminate the output for every scenario with a blank line.

Sample Input

1
4
bg.png 5 7
.-----.
|.....|
|.....|
|.....|
.-----.
eye.jpg 1 1
O
nose.bmp 1 1
v
mouth.png 1 3
<_>
5
#bg {
	pos-x: 1 px;
	pos-y: 1 px;
	position: absolute;
  file: bg.png;
  layer: 0;
} 
#leftEye {
	pos-x: 1 px;
	pos-y: 1 px;
	position: relative=bg;
  file: eye.jpg;
  layer: 1;
} 
#rightEye {
	pos-x: 4 px;
	pos-y: 0 px;
	position: relative=leftEye;
  file: eye.jpg;
  layer: 1;
}
#nose {
  pos-x: 2 px;
  pos-y: 1 px;
  position: relative=leftEye;
  file: nose.bmp;
  layer: 1;
}              
#mouth {
  pos-x: -1 px;
  pos-y: 1 px;
  position: relative = nose;
  file: mouth.png;
  layer: 1;
}

Sample Output

Scenario #1:
        
  ----- 
 |O   O|
 |  v  |
 | <_> |
  ----- 

Source

TUD Programming Contest 2005, Darmstadt, Germany

[Submit]   [Go Back]   [Status]   [Discuss]

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator