• [1605] Beyond the ubuntu

  • 时间限制: 1000 ms 内存限制: 65535 K
  • 问题描述
  •   In our NBUT ACM team, there is a great project, we call it "Nbuntu project". Nbuntu is a new operation system, which has many advantages. It is very fast and uses lower memory, one more important thing is that Nbuntu is much more beautiful than MAC OS, Ubuntu desktop and Redhat desktop.
      As we all know, every system consistes of many modules, so Nbuntu does. Yet we had finished most of its modules except file system. As one of the most excellent NBUT ACM team member, everyone hopes you to finish this hard but perfect work.
      Below is the design of our Nbuntu file system. Nbuntu file system use "/" as its root directory(exclude the double quotation marks) for the tree file system, that means every time you start the system, initially your current directory is /. / is very special, it is the root of everything, you can not delete it because your path is always based on / and you can not switch / as your sub-directory(you can only delete target which is in your current directory). Every directory has a "." and a ".." directory, they are special directories, the first means the current directiry, the second means the parent directory. To operate our Ubuntu file system, we designed six commands: new, mkdir, ls, rm, cd and pwd.
      In order to reduce the difficulty, you can assume every command users input has no spell errors or miss parameters, every file name or directory name, no matter create, delete or type as params in a command, it is valid and no more than 20 characters. Every character is in 0-9 or a-z(only lowercase).
      CMD1: new. Users can use this command to create a file. The usage is "new X", X is the name of the file. If it works, system should output "success.". If there already exist a file or a directory named X in the same directory, then this command failed and should output "Error: File X already exist." or "Error: Directory X already exist.", similarly, X is the name of the file or directory.
      CMD2: mkdir. Users can create a directory in current directory using this command. The usage is "mkdir X", every X in command has the same meaning with command "new", so we are not going to explain it again. If success, system should output "success.". If there already exist a file or a directory named X in current directory, then this command failed and should output "Error: File X already exist." or "Error: Directory X already exist."
      CMD3: ls. This command list all directories and files in current directory. The usage is "ls". The order of list is: ".", "..", directory list and file list, sort by lexicographic order. If current directory is empty, just output "." and "..".
      CMD4: rm. To delete a file or a directory, users use this command. The usage is "rm X". If target deleted successfully, output "success.". If X does not exist, output "Error: Target X not exist.". If users try to delete "." or "..", for this two directories is special, the command is invalid, system should output "Warn: This operation is invalid.".
      CMD5: cd. Cd allows users to switch working directory. Users can type "cd X" to enter a sub-directory, or use "cd .." to back to parent directory. If the command user input is valid, output "success.". But if users cd an exist file, then the command is invalid so output "Error: params should be a valid directory.", or if X does not exist, system will output "Error: Directory not exist."
      CMD6: pwd. This command is simple, it outputs the current directory which usage is "pwd". For example, now you are in the root directory, and you cd into an existing sub-directory named "nbut", then you type "pwd" and pres enter, our system should return and output "/nbut". Notice there is no slash in the end.
      As an excellent student, do not let us disappointed!
  • 输入
  • There are multiply cases. For each case, first line there is a number N(1 <= N <= 50), indicate the number of commands. Then N lines follow. A command a line. See sample input for details.
  • 输出
  • For each test case, for each command, you should output the result of the command.
  • 样例输入
  • cd .
    cd ..
    mkdir nbut
    new acm
    cd nbut
    mkdir acm
    ls
    mkdir icpc
    ls
    cd ..
    ls
    
  • 样例输出
  • success.
    success.
    success.
    success.
    success.
    success.
    .
    ..
    acm
    success.
    .
    ..
    acm
    icpc
    success.
    .
    ..
    nbut
    acm
    
  • 提示
  • 来源
  • 本站或者转载
  • 操作

显示春菜