欢迎来到起遇信息学
起遇信息学正处于上线筹建阶段,以下功能已全部开放免费体验: ✅ 完整题库浏览与代码提交评测(C / C++ / Python / Java 等) ✅ 入门到进阶的系列课程试读、作业与考试 ✅ AI 提示、AI 作业分析等智能助教功能 ✅ 赛事模拟与个人能力报告 ✅ 邮箱注册开放 ⏳ 付费课程订阅与微信/支付宝支付通道 ⏳ 手机号登录,微信扫码登录、微信公众号绑定 使用中如遇任何问题,欢迎通过页面底部 **"联系我们"** 与我们沟通。
CF1729C.Jumping on Tiles
Jumping on Tiles
Polycarp was given a row of tiles. Each tile contains one lowercase letter of the Latin alphabet. The entire sequence of tiles forms the string .
In other words, you are given a string consisting of lowercase Latin letters.
Initially, Polycarp is on the first tile of the row and wants to get to the last tile by jumping on the tiles. Jumping from -th tile to -th tile has a cost equal to , where is the index of the letter in the alphabet (for example, 'a', 'b', ..., 'z') .
Polycarp wants to get to the -th tile for the minimum total cost, but at the same time make maximum number of jumps.
In other words, among all possible ways to get to the last tile for the minimum total cost, he will choose the one with the maximum number of jumps.
Polycarp can visit each tile at most once.
Polycarp asks you to help — print the sequence of indices of string on which he should jump.
Input
The first line of the input contains an integer () — the number of test cases in the test.
Each test case is given by the string (), where — is the length of string . The string consists of lowercase Latin letters.
It is guaranteed that the sum of string lengths over all test cases does not exceed .
Output
The answer to each test case consists of two lines.
In the first line print two integers , , where is the minimum total cost of the path, and is the maximum number of visited tiles Polycarp can make to get to -th tiles for the minimum total cost (i.e. the number of jumps is ).
In the next line print different numbers () — the sequence of indices of the tiles Polycarp will jump on. The first number in the sequence must be (that is, ) and the last number must be the value of (that is, ).
If there are multiple answers, print any of them.
Note
In the first test case, the required path corresponds to the picture:

In this case, the minimum possible total cost of the path is achieved. Since 'l', 'o', 'g', 'i', 'c', then the total cost of the path is .
Samples
6
logic
codeforces
bca
aaaaaaaaaaa
adbaadabad
to
9 4
1 4 3 5
16 10
1 8 3 4 9 5 2 6 7 10
1 2
1 3
0 11
1 8 10 4 3 5 7 2 9 6 11
3 10
1 9 5 4 7 3 8 6 2 10
5 2
1 2
在线编程 IDE
建议全屏模式获得最佳体验
| 进入全屏编程 | Alt+E |
| 递交评测 | Ctrl+Enter |
| 注释/取消注释 | Ctrl+/ |
| 缩放字体 | Ctrl+滚轮 |