Drug interactions V39451


Statement
 

pdf   zip

thehtml

Write a program that loads a list of drug interactions, and then allows the user to query it.

The input has two parts: data and queries.

The data part consists of an integer n indicating how many drug-effect-drug triplets are to be read. Then, there are n lines, each with a drug name, an effect, and another drug name. The drugs names and effect types are not constrained to a limited list.

After the n data lines comes the query part. Here, a line may consists of a drug name and an effect followed by a question mark, or a question mark followed by an effect and a drug name. In the former case, the program must print all the drugs that are affected by the given one with the given effect. On the latter case, the program reports the drugs that have the given effect on the given drug

Input

The input consits of a number n≥0, followed by n triplets drug-effect-drug. After that, there is a sequence of queries, each of them consisting of a question mark and effect and a drug, or a drug, and effect and a question mark.

Output

For each query the list of drugs answering the query, alphabetically sorted. If no drugs are found for the given query, the program prints "not found"

Public test cases
  • Input

    20
    spermidine potentiate opiate
    bezafibrate inhibit antihypertensive
    analgesics activate antihypertensive
    tolterodine enhance enoxacin
    spermidine intercept antihypertensive
    bentoquatam intercept tramadol
    enoxacin enhance opiate
    tramadol activate opiate
    bentoquatam intercept tramadol
    tolterodine enhance analgesics
    analgesics inhibit enoxacin
    anticholinergics inhibit ketorolac
    anticholinergics activate tramadol
    anticholinergics intercept chloramphenicol
    bezafibrate intercept bentoquatam
    antihypertensive activate vasopressors
    vasopressors intercept chloramphenicol
    opiate affect spermidine
    tramadol inhibit bentoquatam
    bezafibrate affect anticholinergics
    
    bentoquatam intercept ?
    ? intercept chloramphenicol
    opiate affect ?
    enoxacin activate ?
    tolterodine enhance ?
    ? inhibit opiate
    

    Output

    Drugs that bentoquatam intercept: tramadol
    Drugs that intercept chloramphenicol: anticholinergics vasopressors
    Drugs that opiate affect: spermidine
    Drugs that enoxacin activate: NOT FOUND
    Drugs that tolterodine enhance: analgesics enoxacin
    Drugs that inhibit opiate: NOT FOUND
    
  • Information
    Author
    Lluís Padró
    Language
    English
    Official solutions
    Python
    User solutions
    Python