logo AlgoBeat OnlineJudge
登录 注册

#216852. [GKS 2021 #H] Silly Substitutions

内存限制:1024 MiB 时间限制:3000 ms 标准输入输出
题目类型:VJudge(洛谷) 评测方式:VJudge
上传者: 匿名

题目描述

You are given a string of length which consists of digits -. You do the following operations on the string in the order given.

  1. Find all the substrings and replace each of them with .
  2. Find all the substrings and replace each of them with .
  3. Find all the substrings and replace each of them with .
  4. Find all the substrings and replace each of them with .
  5. Find all the substrings and replace each of them with .
  6. Find all the substrings and replace each of them with .
  7. Find all the substrings and replace each of them with .
  8. Find all the substrings and replace each of them with .
  9. Find all the substrings and replace each of them with .
  10. Find all the substrings and replace each of them with .

You repeat this process in the same given order until none of the above operations change the string. For example, if is then we do not stop at operation since it does not affect the string but perform operation and change the string to . We can see that the string does not change further no matter how many times we repeat the above process.

Your task is to find how the final string will look like for the given .

输入格式

The first line of the input gives the number of test cases, . test cases follow. Each test case consists of two lines.

The first line of each test case contains an integer , denoting the length of the string .

The second line of each test case contains a string of length .

输出格式

For each test case, output one line containing Case #: , where is the test case number (starting from ) and is the final string obtained.

样例

样例输入 1

4
3
012
4
0145
5
00000
11
98765432101

样例输出 1

Case #1: 22
Case #2: 26
Case #3: 00000
Case #4: 1

数据范围与提示

In Sample Case #, substring is replaced with and the resulting string is which is not affected further by any of the operations. Therefore final string is .

In Sample Case #, substring is replaced with and the resulting string is . The substring is replaced with and the resulting string is which is not further affected by any of the operations. Therefore final string is .

In Sample Case #, since the operations cannot be performed on the given string, the string does not change.

In Sample Case #, all the operations can be performed sequentially on the string and the final string is .

Limits

.

The input string only consists of digits -.

Test Set

.

Test Set

For at most cases:

.

For the remaining cases:

.