시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
서브태스크 참고 | 1024 MB | 92 | 31 | 14 | 35.000% |
You are given a string $S$ of length $N$ which consists of digits 0-9
. You do the following operations on the string in the order given.
01
and replace each of them with 2
.12
and replace each of them with 3
.23
and replace each of them with 4
.34
and replace each of them with 5
..
.
.
89
and replace each of them with 0
.90
and replace each of them with 1
.You repeat this process in the same given order until none of the above operations change the string. For example, if $S$ is 12
then we do not stop at operation $1$ since it does not affect the string but perform operation $2$ and change the string to 3
. 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 $S$.
The first line of the input gives the number of test cases, $T$. $T$ test cases follow. Each test case consists of two lines.
The first line of each test case contains an integer $N$, denoting the length of the string $S$.
The second line of each test case contains a string $S$ of length $N$.
For each test case, output one line containing Case #x: y
, where $x$ is the test case number (starting from 1) and $y$ is the final string obtained.
0-9
.시간 제한: 20 초
시간 제한: 60 초
For at most 10 cases:
For the remaining cases:
4 3 012 4 0145 5 00000 11 98765432101
Case #1: 22 Case #2: 26 Case #3: 00000 Case #4: 1
In Sample Case #1, substring 01
is replaced with 2
and the resulting string is 22
which is not affected further by any of the operations. Therefore final string is 22
.
In Sample Case #2, substring 01
is replaced with 2
and the resulting string is 245
. The substring 45
is replaced with 6
and the resulting string is 26
which is not further affected by any of the operations. Therefore final string is 26
.
In Sample Case #3, since the operations cannot be performed on the given string, the string does not change.
In Sample Case #4, all the operations can be performed sequentially on the string and the final string is 1
.
Contest > Google > Kick Start > Google Kick Start 2021 > Round H C번