#P10691. [SNCPC2024] chmod
[SNCPC2024] chmod
Problem Description
is a command used to change file or directory permissions. It is one of the commonly used commands in Linux and other Unix-like operating systems. The command allows users to set different permissions for files or directories, to control who can read, write, or execute them.
In a Linux system, each file or directory has associated permissions, which decide what operations different users can perform on the file. Users are divided into three categories: owner, group, and others. Each category has three kinds of permissions: read (r), write (w), and execute (x). These permissions can be specified separately. We call a permission string a string of length , whose characters in order correspond to the above permissions. If the permission is granted, it is the corresponding one of , , ; otherwise it is .
For example, the permission string means that the file has all permissions for the owner, only read and execute permissions for users in the group, and only execute permission for others.
When using the command, you can provide a mode string to modify permissions. In this problem, we only consider mode strings of length consisting of digits not greater than . The three digits from left to right represent the permissions of the owner, group, and others, respectively. For each digit, its lowest three binary bits from high to low indicate whether this category of users has read (r), write (w), and execute (x) permissions.
For example, after executing , the file’s permission string is .
Given several valid mode strings, each time you read one mode string, you need to output the updated file’s permission string.
Input Format
The first line contains a positive integer (), which indicates the number of test cases.
Then follow lines, each containing one mode string.
Output Format
Output lines in total, where each line is the permission string corresponding to the given mode string.
3
356
114
514
-wxr-xrw-
--x--xr--
r-x--xr--
Hint
Translated by ChatGPT 5