Cascading Style Sheets
All submissions for this problem are available.
Read problems statements in Mandarin Chinese and Russian.
Cascading Style Sheets, or CSS is a style sheet language, most popularly known for styling web pages. Each object on a web page (like a picture, a paragraph, a table) can have various properties (like height, width, size, colour), and these properties can be set using CSS. Each of these objects has a unique identifier called id, using which CSS can identify the object and assign value to its property.
Due to hierarchical nature of the web page, often same property of an object gets assigned different values in different CSS statements. To decide what the final value will be, each statement has a priority assigned to it. The statement with the highest priority will be the one that sets the value of the property. If there are more than one statements with same priority, then the one which was executed last amongst those will set the value.
Given multiple CSS statements in the order they were executed, answer a few queries about the final values of certain objects
First line contains two space-separated integers N and M, the number of CSS statements and the number of queries respectively.
Following N lines will each have 4 values id, attr, val, priority, which mean that a CSS statement tries to assign value val to the attribute named attr of the object id, and that the priority of this statement is equal to priority.
Each of the next M lines will contain two values id and attr, for which you have to print value of the attribute attr of object id. You can assume that there is a statement that assigns value to this attribute attr of object id.
Print exactly M lines, ith line contains the answer to the ith query as described above.
22 1 200 2
22 1 300 2
22 1 100 1
|Tags||easy, hash-map, ltime17, piyushkumar|
|Time Limit:||1 sec|
|Source Limit:||50000 Bytes|
|Languages:||ADA, ASM, BASH, BF, C, C99 strict, CAML, CLOJ, CLPS, CPP 4.3.2, CPP 6.3, CPP14, CS2, D, ERL, FORT, FS, GO, HASK, ICK, ICON, JAVA, JS, LISP clisp, LISP sbcl, LUA, NEM, NICE, NODEJS, PAS fpc, PAS gpc, PERL, PERL6, PHP, PIKE, PRLG, PYTH, PYTH 3.5, RUBY, SCALA, SCM guile, SCM qobi, ST, TCL, TEXT, WSPC|
Fetching successful submissions
If you are still having problems, see a sample solution here.