欢迎来到起遇信息学
起遇信息学正处于上线筹建阶段,以下功能已全部开放免费体验: ✅ 完整题库浏览与代码提交评测(C / C++ / Python / Java 等) ✅ 入门到进阶的系列课程试读、作业与考试 ✅ AI 提示、AI 作业分析等智能助教功能 ✅ 赛事模拟与个人能力报告 ✅ 邮箱注册开放 ⏳ 付费课程订阅与微信/支付宝支付通道 ⏳ 手机号登录,微信扫码登录、微信公众号绑定 使用中如遇任何问题,欢迎通过页面底部 **"联系我们"** 与我们沟通。
CF1729B.Decode String
Decode String
Polycarp has a string consisting of lowercase Latin letters.
He encodes it using the following algorithm.
He goes through the letters of the string from left to right and for each letter Polycarp considers its number in the alphabet:
- if the letter number is single-digit number (less than ), then just writes it out;
- if the letter number is a two-digit number (greater than or equal to ), then it writes it out and adds the number
0after.
For example, if the string is code, then Polycarp will encode this string as follows:
- '
c' — is the -rd letter of the alphabet. Consequently, Polycarp adds3to the code (the code becomes equal to3); - '
o' — is the -th letter of the alphabet. Consequently, Polycarp adds15to the code and also0(the code becomes3150); - '
d' — is the -th letter of the alphabet. Consequently, Polycarp adds4to the code (the code becomes31504); - '
e' — is the -th letter of the alphabet. Therefore, Polycarp adds5to the code (the code becomes315045).
Thus, code of string code is 315045.
You are given a string resulting from encoding the string . Your task is to decode it (get the original string by ).
Input
The first line of the input contains an integer () — the number of test cases in the input.
The descriptions of the test cases follow.
The first line of description of each test case contains one integer () — the length of the given code.
The second line of the description of each test case contains a string of length — the given code. It is guaranteed that there exists such a string of lowercase Latin letters, as a result of encoding which the string is obtained.
Output
For each test case output the required string — the string that gives string as the result of encoding. It is guaranteed that such a string always exists. It can be shown that such a string is always unique.
Note
The first test case is explained above.
In the second test case, the answer is aj. Indeed, the number of the letter a is equal to , so 1 will be appended to the code. The number of the letter j is , so 100 will be appended to the code. The resulting code is 1100.
There are no zeros in the third test case, which means that the numbers of all letters are less than and are encoded as one digit. The original string is abacaba.
In the fourth test case, the string is equal to ll. The letter l has the number and is encoded as 120. So ll is indeed 120120.
Samples
9
6
315045
4
1100
7
1213121
6
120120
18
315045615018035190
7
1111110
7
1111100
5
11111
4
2606
code
aj
abacaba
ll
codeforces
aaaak
aaaaj
aaaaa
zf
在线编程 IDE
建议全屏模式获得最佳体验
| 进入全屏编程 | Alt+E |
| 递交评测 | Ctrl+Enter |
| 注释/取消注释 | Ctrl+/ |
| 缩放字体 | Ctrl+滚轮 |