14766 - The Great Tariff Cleanup   

Description

President Trump has once again taken matters into his own hands, this time, to “fix” the global economy by personally deleting every tariff policy ever made. Naturally, the policies are stored in a complicated nested folder system, because what’s more “simple” than thousands of trade files inside /root

Your job is to simulate the behavior of the Unix command rm -r, recursively wiping out every folder and file in post-order traversal. Just make sure to print each deletion path — after all, he’ll probably want to tweet about how “tremendously efficient” his cleanup was.


The folder structure is represented as an n-ary tree, written as a nested list.
Each node is represented as:

[name, [child1, child2, child3, ...]]

That is,

  • t[0] is the name of the current folder or file
  • t[1:] (if any) are its subtrees (children)

You must recursively delete all nodes in post-order traversal, meaning all children are deleted before their parent node. For each deletion, output the full path of the node, starting from the root (prefixed with /).

Input

The input consists of a single line containing a valid list representation of an n-ary tree.
 The list uses the following format:

[name, [child1, child2, ...]]

Constraints:

  • All names consist only of lowercase English letters, digits, periods (.), or underscores (_) — no spaces.
  • The root node’s name is always "root".
  • The input list is guaranteed to be a valid Python list that can be parsed safely using ast.literal_eval().

NOTE:
You can use Python’s ast.literal_eval() to safely convert the string input into a list structure before processing.
For example:

import ast
tree = ast.literal_eval(input().strip())

Then you can recursively traverse the tree to perform the deletions.

Output

Print the deletion order in post-order traversal.

Each line should be in the form:

Deleting <full_path>

where <full_path> is the absolute path to the node starting from /root.

Sample Input  Download

Sample Output  Download




Discuss