TLE '16 Contest 6 (Mock CCC) S1 - Writing the CCC

View as PDF

Submit solution


Points: 5 (partial)
Time limit: 2.0s
Memory limit: 256M

Author:
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
Sample problem: Can you name this compound? (Bonus: Use this compound to describe somebody.)

The CS Nerd thinks that he can impress the girl by performing well in contests. As a result, he has decided to write the CCC (Canadian Chemistry Competition).

Surprisingly, there are only T types of chemistry problems in existence! The T types of problems will be listed in order of the CS nerd's preference for that type of problem. That is, the i^{th} type is preferred over the j^{th} type if i < j.

The CCC consists of N problems, numbered from 1 to N. The CS Nerd scans through the problems and quickly determines the type of each problem. He would like to complete the problems in order of preferred problem type, breaking ties by solving earlier problems. In what order should he complete the problems in?

Input Specification

The first line of input will contain a single integer, T (1 \le T \le 10^5).

The next T lines of input will each contain a string with a maximum of 20 characters, consisting of only lowercase English letters. The i^{th} line specifies the i^{th} type of problem. No two lines will contain the same string.

The next line of input will contain a single integer, N (1 \le N \le 10^5).

The next N lines of input will each contain a string. The k^{th} line specifies the problem type of the k^{th} problem. It is guaranteed that each string was present in the T lines of input specifying the problem types.

For 4 of the 15 points, T \le 2.

For an additional 6 of the 15 points, T,N \le 1\,000.

Output Specification

The output will consist of N lines. On the i^{th} line, output a single integer specifying the i^{th} problem that the CS nerd should complete.

Sample Input

5
equilibrium
trivial
organic
lab
adhoc
7
trivial
organic
adhoc
equilibrium
trivial
lab
adhoc

Sample Output

4
1
5
2
6
3
7

Comments


  • 8
    infernooo  commented on Feb. 20, 2019, 11:30 a.m.

    Aflatoxin

    League community:

    Aflatoxins are a family of toxins produced by certain fungi that are found on agricultural crops such as maize (corn), peanuts, cottonseed, and tree nuts. The main fungi that produce aflatoxins are Aspergillus flavus and Aspergillus parasiticus, which are abundant in warm and humid regions of the world.

    yw saved you 2 minutes of searching on chemspider.


  • -2
    yellowsn0w1004  commented on Feb. 20, 2017, 8:18 p.m.

    Does the CCC care how long your program takes to run? In other words, do they care about program speed?


    • 2
      d  commented on Feb. 20, 2017, 8:20 p.m.

      Yes.


      • -1
        yellowsn0w1004  commented on Feb. 20, 2017, 8:21 p.m.

        Do you know what the time limit is?


        • -6
          yasung  commented on Feb. 21, 2017, 1:08 a.m.

          This comment is hidden due to too much negative feedback. Click here to view it.


          • 3
            kobortor  commented on Feb. 21, 2017, 8:09 a.m.

            It changes for each problem.


  • 30
    jihua5758  commented on Feb. 20, 2017, 12:10 p.m.

    do it get extra marks for naming that?


    • 4
      ZQFMGB12  commented on Feb. 20, 2017, 12:16 p.m.

      You get an upvote.


  • 2
    Ken_Shi  commented on Feb. 20, 2017, 11:57 a.m.

    I cant do this problem cuz c does not contain string! using 2D char array I need a size of the string!


    • 2
      ZQFMGB12  commented on Feb. 20, 2017, 12:54 p.m.

      Each string will have a maximum of 20 characters, as stated in the problem description.


      • -2
        Ken_Shi  commented on Feb. 20, 2017, 1:02 p.m.

        Thx for pointing out! I will check my algorithm\(None\)