WOSS Dual Olympiad 2021 J2/S1: Secret Formula

View as PDF

Submit solution

Points: 3
Time limit: 2.0s
Memory limit: 256M

Authors:
Problem type

You have heard rumours of a secret, super-strong compound with a formula that has been lost up until now. You have found a sheet describing a cipher used to encode the formula for this compound, along with a list of coded versions of potential formulas.

The cipher functions as follows: each number from 0-9 is assigned a specific character that it represents. Whenever the number appears in a coded formula, it is to be replaced with the character that it represents.

Due to there being a large number of potential formulas, you wish to automate the decoding process by writing a program to take in the cipher along with a coded version of the formula and output the decoded version.

Input Specification

There will be three lines of input.

The first line will contain 10 space-separated characters (letters or numbers), each of which represents the decoded version of a number from 0-9, in that order.

The second line will contain an integer N (1 \le N \le 1000), which represents the number of numbers from 0-9 that make up the coded version of the compound.

The third line will contain N space-separated integers from 0-9, which is the coded version of the compound.

Output Specification

Output the decoded version of the input.

Sample Input

4 1 C H N Y X M 2 O
10
2 1 0 3 1 0 4 8 9 0

Sample Output

C14H14N2O4

Explanation of Sample Input/Output

2 - C
1 - 1
0 - 4
3 - H
1 - 1
0 - 4
4 - N
8 - 2
9 - O
0 - 4

Fun Fact: C14H14N2O4 is actually the chemical formula for Kevlar!


Comments

There are no comments at the moment.