#C2896. Role Authorization Checker

    ID: 46262 Type: Default 1000ms 256MiB

Role Authorization Checker

Role Authorization Checker

You are given a roles dictionary and a list of user roles in which each key in the dictionary corresponds to a role and its associated value is a list of allowed actions. Given a requested action, determine if the user is authorized to perform that action. In other words, if there exists a role r in the user's roles such that the requested action is in the allowed actions for r, then the answer is True, otherwise False.

You can express the condition mathematically as:

[ \exists, r \in \text{user_roles} \text{ such that } \text{requested_action} \in \text{roles}[r] ]

The input is read from standard input and the output is printed to standard output.

inputFormat

The input consists of three lines:

  1. A JSON string representing the roles dictionary. For example: {"admin": ["create", "read", "update", "delete"], "editor": ["create", "read", "update"], "viewer": ["read"]}
  2. A JSON string representing the list of user roles. For example: ["editor", "viewer"]
  3. A string representing the requested action. For example: update

outputFormat

Output a single line: True if the user is authorized to perform the action, or False otherwise.

## sample
{"admin": ["create", "read", "update", "delete"], "editor": ["create", "read", "update"], "viewer": ["read"]}
["editor", "viewer"]
update
True