CF1703C.Cypher

入门

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Luca has a cypher made up of a sequence of nn wheels, each with a digit aia_i written on it. On the ii-th wheel, he made bib_i moves. Each move is one of two types:

  • up move (denoted by U\texttt{U}): it increases the ii-th digit by 11. After applying the up move on 99, it becomes 00.
  • down move (denoted by D\texttt{D}): it decreases the ii-th digit by 11. After applying the down move on 00, it becomes 99.

Example for n=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.

卢卡有一个由 nn 个转轮组成的密码装置,每个转轮上写有一个数字 aia_i。在第 ii 个转轮上,他执行了 bib_i 次操作。每次操作为以下两种类型之一:

  • 上移操作(记为 U\texttt{U}):将第 ii 个数字加 11;对数字 99 执行上移操作后,结果变为 00。
  • 下移操作(记为 D\texttt{D}):将第 ii 个数字减 11;对数字 00 执行下移操作后,结果变为 99。

示例:n=4n=4。当前序列为 0 0 0 0。

卢卡已知所有转轮的最终序列以及每个转轮上执行的操作序列。请帮助他还原初始序列,从而破解该密码。

输入格式

The first line contains a single integer tt (1≤t≤1001 \leq t \leq 100) — the number of test cases.

The first line of each test case contains a single integer nn (1≤n≤1001 \leq n \leq 100) — the number of wheels.

The second line contains nn integers aia_i (0≤ai≤90 \leq a_i \leq 9) — the digit shown on the ii-th wheel after all moves have been performed.

Then nn lines follow, the ii-th of which contains the integer bib_i (1≤bi≤101 \leq b_i \leq 10) and bib_i characters that are either U\texttt{U} or D\texttt{D} — the number of moves performed on the ii-th wheel, and the moves performed. U\texttt{U} and D\texttt{D} represent an up move and a down move respectively.

第一行包含一个整数 tt(1≤t≤1001 \leq t \leq 100)——测试用例的数量。

每个测试用例的第一行包含一个整数 nn(1≤n≤1001 \leq n \leq 100)——轮子的数量。

第二行包含 nn 个整数 aia_i(0≤ai≤90 \leq a_i \leq 9)——所有操作执行完毕后,第 ii 个轮子上显示的数字。

接下来是 nn 行,其中第 ii 行包含一个整数 bib_i(1≤bi≤101 \leq b_i \leq 10)以及 bib_i 个字符,每个字符为 U\texttt{U} 或 D\texttt{D} —— 表示在第 ii 个轮子上执行的操作次数及具体操作。U\texttt{U} 和 D\texttt{D} 分别代表向上拨动和向下拨动。

输出格式

For each test case, output nn space-separated digits — the initial sequence of the cypher.

对于每个测试用例,输出 nn 个空格分隔的数字——即该密码的初始序列。

输入输出样例

  • 输入#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][2,1,1]. In that case, the following moves were performed:

  • On the first wheel: 2→D1→D0→D92 \xrightarrow[\texttt{D}]{} 1 \xrightarrow[\texttt{D}]{} 0 \xrightarrow[\texttt{D}]{} 9.
  • On the second wheel: 1→U2→D1→U2→U31 \xrightarrow[\texttt{U}]{} 2 \xrightarrow[\texttt{D}]{} 1 \xrightarrow[\texttt{U}]{} 2 \xrightarrow[\texttt{U}]{} 3.
  • On the third wheel: 1→D0→U11 \xrightarrow[\texttt{D}]{} 0 \xrightarrow[\texttt{U}]{} 1.

The final sequence was [9,3,1][9,3,1], which matches the input.

在第一个测试用例中,我们可以证明初始序列为 [2,1,1][2,1,1]。此时执行了以下操作:

  • 在第一个转轮上:2→D1→D0→D92 \xrightarrow[\texttt{D}]{} 1 \xrightarrow[\texttt{D}]{} 0 \xrightarrow[\texttt{D}]{} 9。
  • 在第二个转轮上:1→U2→D1→U2→U31 \xrightarrow[\texttt{U}]{} 2 \xrightarrow[\texttt{D}]{} 1 \xrightarrow[\texttt{U}]{} 2 \xrightarrow[\texttt{U}]{} 3。
  • 在第三个转轮上:1→D0→U11 \xrightarrow[\texttt{D}]{} 0 \xrightarrow[\texttt{U}]{} 1。

最终序列为 [9,3,1][9,3,1],与输入一致。

输入解题思路,AI测评打分。不知道怎么写?

首页