CF1703C.Cypher
入门
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
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 1. After applying the up move on 9, it becomes 0.
- down move (denoted by D): it decreases the i-th digit by 1. After applying the down move on 0, it becomes 9.
Example for n=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.
卢卡有一个由 n 个转轮组成的密码装置,每个转轮上写有一个数字 ai。在第 i 个转轮上,他执行了 bi 次操作。每次操作为以下两种类型之一:
- 上移操作(记为 U):将第 i 个数字加 1;对数字 9 执行上移操作后,结果变为 0。
- 下移操作(记为 D):将第 i 个数字减 1;对数字 0 执行下移操作后,结果变为 9。
示例:n=4。当前序列为 0 0 0 0。
卢卡已知所有转轮的最终序列以及每个转轮上执行的操作序列。请帮助他还原初始序列,从而破解该密码。
输入格式
The first line contains a single integer t (1≤t≤100) — the number of test cases.
The first line of each test case contains a single integer n (1≤n≤100) — the number of wheels.
The second line contains n integers ai (0≤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≤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.
第一行包含一个整数 t(1≤t≤100)——测试用例的数量。
每个测试用例的第一行包含一个整数 n(1≤n≤100)——轮子的数量。
第二行包含 n 个整数 ai(0≤ai≤9)——所有操作执行完毕后,第 i 个轮子上显示的数字。
接下来是 n 行,其中第 i 行包含一个整数 bi(1≤bi≤10)以及 bi 个字符,每个字符为 U 或 D —— 表示在第 i 个轮子上执行的操作次数及具体操作。U 和 D 分别代表向上拨动和向下拨动。
输出格式
For each test case, output n space-separated digits — the initial sequence of the cypher.
对于每个测试用例,输出 n 个空格分隔的数字——即该密码的初始序列。
输入输出样例
输入#1
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
输出#1
2 1 1 9 0 0 4 9 6 9
说明/提示
In the first test case, we can prove that initial sequence was [2,1,1]. In that case, the following moves were performed:
- On the first wheel: 2D1D0D9.
- On the second wheel: 1U2D1U2U3.
- On the third wheel: 1D0U1.
The final sequence was [9,3,1], which matches the input.
在第一个测试用例中,我们可以证明初始序列为 [2,1,1]。此时执行了以下操作:
- 在第一个转轮上:2D1D0D9。
- 在第二个转轮上:1U2D1U2U3。
- 在第三个转轮上:1D0U1。
最终序列为 [9,3,1],与输入一致。
输入解题思路,AI测评打分。不知道怎么写?