## DWITE '10 R5 #1 - Colourful Words

View as PDF

Points: 5
Time limit: 2.0s
Memory limit: 64M

Problem type
Allowed languages
Ada, Assembly, Awk, Brain****, C, C#, C++, COBOL, CommonLisp, D, Dart, F#, Forth, Fortran, Go, Groovy, Haskell, Intercal, Java, JS, Kotlin, Lisp, Lua, Nim, ObjC, OCaml, Octave, Pascal, Perl, PHP, Pike, Prolog, Python, Racket, Ruby, Rust, Scala, Scheme, Sed, Swift, TCL, Text, Turing, VB, Zig
##### DWITE Online Computer Programming Contest, February 2011, Problem 1

Colour has often been added to words to make them seem more attractive or distinct (take the Google logo for example). However, taking a look at coloured words under coloured light makes the letters in the word that has the same colour as the light seem invisible. For example, say I have the word DWITE, and its letters are coloured blue, red, red, green and blue respectively. If you looked at the word under red light, you would only see D__TE (note the underscores, representing positions, where the W and I have been). Given coloured words and the light they are observed under, determine what you would see.

The input will contain 5 test cases. The first line of each test case consists of two words (strings with no spaces) and , representing the word and the colour of each letter of the word respectively (so the th letter of determines the colour of the th letter of , where the possible colours are b for blue, r for red, and g for green). The next line contains a string , representing the colour of the light. consists of either a b, r, or g (representing blue, red and green), or any combination of these letters separated by +s.

The output should consist of 5 lines, where each line contains the given word as it appears under the given light. Invisible letters are to be represented with _ underscores.

Note: There are 3 under scores after Compu in the third line of output, and the last line of output contains 5 under scores. It is also assumed that combined colours remove letters of either individual component in the combination.

#### Sample Input

Sample rggbbr
b
DWITE brrgb
r
Computer bbbbbrrg
r+g
February brbrbrbr
g
Sweet brgbr
r+g+b

#### Sample Output

Sam__e
D__TE
Compu___
February
_____