#C3195. Finding Large Files in a File System

    ID: 46595 Type: Default 1000ms 256MiB

Finding Large Files in a File System

Finding Large Files in a File System

You are given a description of a file system containing directories and files. Each directory is represented as a node with a name and an optional parent, and each file is represented with its name, size, and the parent directory in which it resides.

Your task is to list all file paths in the file system having file sizes strictly greater than a given threshold \(T\) (i.e. \(\text{size} > T\)). For each file that qualifies, output its full path by concatenating the names of its parent directories (from the top-level directory) and the file name, using a forward slash (/) as the separator. If no file’s size exceeds the threshold, output the string "No large files" for that test case.

Note:

  • The input begins with an integer denoting the number of test cases. For each test case, the first line is an integer \(N\) representing the total number of nodes (directories and files).
  • Then \(N\) lines follow, each describing either a directory in the format D [directory_name] [parent_directory] or a file in the format F [file_name] [size] [parent_directory].
  • After the \(N\) lines, there is a threshold integer \(T\).
  • The output for each test case should be a single line. If there is at least one file with a size greater than \(T\), print the lexicographically sorted file paths separated by a single space; otherwise, print "No large files".

inputFormat

The input is read from standard input (stdin) in the following format:

T
N
[node_1]
[node_2]
... 
[node_N]
T
...
  • T: Number of test cases.
  • For each test case:
    • N: The number of nodes (directories/files).
    • Next \(N\) lines: each line is either:
      • D [directory_name] [parent_directory] for a directory. The parent directory may be omitted, in which case it is considered the top-level.
      • F [file_name] [size] [parent_directory] for a file.
    • Last line for the test case: an integer representing the threshold \(T\).

outputFormat

For each test case, print a single line to standard output (stdout) containing:

  • If there are files with size greater than \(T\), print the full paths of these files (constructed by concatenating directory names from the root and the file name, separated by '/'), sorted in lexicographical order and separated by a single space.
  • If no file exceeds the threshold, print "No large files".
## sample
1
6
D root
F file1.txt 500 root
F file2.txt 1500 root
D subdir root
F file3.txt 1000 subdir
F file4.txt 2000 subdir
1000
root/file2.txt root/subdir/file4.txt