#P17287. [Algo Beat Contest 013 & MSOI R2] 付之一笑
[Algo Beat Contest 013 & MSOI R2] 付之一笑
Background

"Whether you gain or lose, just laugh it off."
Problem Description
You are given ciphertexts. Each ciphertext consists of lowercase letters and “garbled codes”. There are kinds of “garbled codes”, which are the Arabic numerals from to . The letter corresponding to is , corresponds to , and so on.
Now you are given an operation value :
- When equals , you need to convert all “garbled codes” in the ciphertext into lowercase letters. Specifically, you should treat each maximal consecutive digit segment as one “garbled code” and translate it into a single letter.
- When equals , you need to convert all lowercase letters in the ciphertext into “garbled codes”.
Input Format
The first line contains an integer , meaning there are ciphertexts.
In the next lines, each line contains an integer and a string , representing the operation value and the ciphertext, respectively.
Output Format
Output lines. Each line contains the ciphertext after performing the required operation.
3
1 a9y3tf2p25p
2 jzc8ph4ph4ph
2 ph12pjzc21noi20ag26
aiyctfbpyp
10263816841684168
1681216102632114159201726
Hint
Constraints
This problem uses bundled testdata.
::cute-table{tuack}
| Subtask ID | Special Property | Score | ||
|---|---|---|---|---|
| , and the garbled codes only include to | ||||
| ^ | , and the ciphertext only includes lowercase letters | |||
| The garbled codes only include to | ||||
| None |
For all data, it holds that:
- It is guaranteed that the ciphertext contains only lowercase letters and digit characters.
- When , the number represented by every maximal consecutive digit segment in the ciphertext is within .
Translated by ChatGPT 5