[Solution] Cypher Codeforces Solution | Solution Codeforces
Cypher solution codeforces – Luca has a cypher made up of a sequence of 𝑛n wheels, each with a digit 𝑎𝑖ai written on it. On the 𝑖i-th wheel, he made 𝑏𝑖bi moves. Each move is one of two types:
up move (denoted by 𝚄U): it increases the 𝑖i-th digit by 11. After applying the up move on 99, it becomes 00.
down move (denoted by 𝙳D): it decreases the 𝑖i-th digit by 11. After applying the down move on 00, it becomes 99.
Cypher solution codeforcesExample for 𝑛=4n=4. The current sequence is 0 0 0 0.
Luca knows the final sequence of wheels and the moves for each wheel. Help him find the original sequence and crack the cypher.
👇👇👇👇👇
The first line contains a single integer 𝑡t (1≤𝑡≤1001≤t≤100) — the number of test cases.
The first line of each test case contains a single integer 𝑛n (1≤𝑛≤1001≤n≤100) — the number of wheels.
The second line contains 𝑛n integers 𝑎𝑖ai (0≤𝑎𝑖≤90≤ai≤9) — the digit shown on the 𝑖i-th wheel after all moves have been performed.
Then 𝑛n lines follow, the 𝑖i-th of which contains the integer 𝑏𝑖bi (1≤𝑏𝑖≤101≤bi≤10) and 𝑏𝑖bi characters that are either 𝚄U or 𝙳D — the number of moves performed on the 𝑖i-th wheel, and the moves performed. 𝚄U and 𝙳D represent an up move and a down move respectively.
Output
For each test case, output 𝑛n space-separated digits — the initial sequence of the cypher.
[Solution] Cypher solution codeforces
Example
input
Copy
3
3
9 3 1
3 DDD
4 UDUU
2 DU
2
0 9
9 DDDDDDDDD
9 UUUUUUUUU
5
0 5 9 8 3
10 UUUUUUUUUU
3 UUD
8 UUDUUDDD
10 UUDUUDUDDU
4 UUUU
output
Copy
2 1 1
9 0
0 4 9 6 9
[Solution] Cypher solution codeforces
In the first test case, we can prove that initial sequence was [2,1,1][2,1,1]. In that case, the following moves were performed:
On the first wheel: 2−→𝙳1−→𝙳0−→𝙳92→D1→D0→D9.
On the second wheel: 1−→𝚄2−→𝙳1−→𝚄2−→𝚄31→U2→D1→U2→U3.
On the third wheel: 1−→𝙳0−→𝚄11→D0→U1.
The final sequence was [9,3,1][9,3,1], which matches the input.
No comments:
Post a Comment