309588: CF1703C. Cypher

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:4 Solved:0

Description

Cypher

题意翻译

## 题目描述 有一把 $n$ 个锁轮的锁,每个锁轮上写有数字 $a_i$ ,对于第 $i$ 个锁轮,做了 $b_i$ 次操作。这些操作有两种类型: - `U`:锁轮上的数字 $+1$ ,超过 $9$ 则变为 $0$ 。 - `D`:锁轮上的数字 $-1$ ,小于 $0$ 则变为 $9$ 。 现在给定操作后的锁轮和操作,请你还原操作前的锁轮。 ## 输入格式 第一行一个整数 $t$ ,表示测试点内数据组数。 每组数据中第一行是一个正整数 $n$ ,表示锁轮数。 下一行有 $n$ 个整数 $a_i$ ,表示每个锁轮操作后的数字。 以下 $a_i$ 行,第 $i$ 行包含整数 $b_i$ 和 $b_i$ 个字符 `U` 或 `D` ,含义见题目描述。 ## 输出格式 一行 $n$ 个用空格隔开的整数,表示操作前锁轮上的数字。 ## 数据范围 $1 \le n,t \le 100,0 \le a_i \le 9,1 \le b_i \le 10$

题目描述

Luca has a cypher made up of a sequence of $ n $ wheels, each with a digit $ a_i $ written on it. On the $ i $ -th wheel, he made $ b_i $ moves. Each move is one of two types: - up move (denoted by $ \texttt{U} $ ): it increases the $ i $ -th digit by $ 1 $ . After applying the up move on $ 9 $ , it becomes $ 0 $ . - down move (denoted by $ \texttt{D} $ ): it decreases the $ i $ -th digit by $ 1 $ . After applying the down move on $ 0 $ , it becomes $ 9 $ . ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF1703C/d683a49a88f2c28777325d7c0c1b5d00672fd9e9.png)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.

输入输出格式

输入格式


The first line contains a single integer $ t $ ( $ 1 \leq t \leq 100 $ ) — the number of test cases. The first line of each test case contains a single integer $ n $ ( $ 1 \leq n \leq 100 $ ) — the number of wheels. The second line contains $ n $ integers $ a_i $ ( $ 0 \leq a_i \leq 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 $ b_i $ ( $ 1 \leq b_i \leq 10 $ ) and $ b_i $ characters that are either $ \texttt{U} $ or $ \texttt{D} $ — the number of moves performed on the $ i $ -th wheel, and the moves performed. $ \texttt{U} $ and $ \texttt{D} $ represent an up move and a down move respectively.

输出格式


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

输入输出样例

输入样例 #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: $ 2 \xrightarrow[\texttt{D}]{} 1 \xrightarrow[\texttt{D}]{} 0 \xrightarrow[\texttt{D}]{} 9 $ . - On the second wheel: $ 1 \xrightarrow[\texttt{U}]{} 2 \xrightarrow[\texttt{D}]{} 1 \xrightarrow[\texttt{U}]{} 2 \xrightarrow[\texttt{U}]{} 3 $ . - On the third wheel: $ 1 \xrightarrow[\texttt{D}]{} 0 \xrightarrow[\texttt{U}]{} 1 $ . The final sequence was $ [9,3,1] $ , which matches the input.

Input

题意翻译

## 题目描述 有一把 $n$ 个锁轮的锁,每个锁轮上写有数字 $a_i$ ,对于第 $i$ 个锁轮,做了 $b_i$ 次操作。这些操作有两种类型: - `U`:锁轮上的数字 $+1$ ,超过 $9$ 则变为 $0$ 。 - `D`:锁轮上的数字 $-1$ ,小于 $0$ 则变为 $9$ 。 现在给定操作后的锁轮和操作,请你还原操作前的锁轮。 ## 输入格式 第一行一个整数 $t$ ,表示测试点内数据组数。 每组数据中第一行是一个正整数 $n$ ,表示锁轮数。 下一行有 $n$ 个整数 $a_i$ ,表示每个锁轮操作后的数字。 以下 $a_i$ 行,第 $i$ 行包含整数 $b_i$ 和 $b_i$ 个字符 `U` 或 `D` ,含义见题目描述。 ## 输出格式 一行 $n$ 个用空格隔开的整数,表示操作前锁轮上的数字。 ## 数据范围 $1 \le n,t \le 100,0 \le a_i \le 9,1 \le b_i \le 10$

Output

**题意翻译**

题目描述:
有一个有 $ n $ 个锁轮的锁,每个锁轮上写有一个数字 $ a_i $,对于第 $ i $ 个锁轮,执行了 $ b_i $ 次操作。这些操作有两种类型:

- `U`:锁轮上的数字加 1,如果超过 9 则变为 0。
- `D`:锁轮上的数字减 1,如果小于 0 则变为 9。

现在给定操作后的锁轮和操作,请你还原操作前的锁轮。

输入格式:
第一行一个整数 $ t $,表示测试点内数据组数。

每组数据中第一行是一个正整数 $ n $,表示锁轮数。

下一行有 $ n $ 个整数 $ a_i $,表示每个锁轮操作后的数字。

接下来 $ a_i $ 行,第 $ i $ 行包含整数 $ b_i $ 和 $ b_i $ 个字符 `U` 或 `D`,具体含义见题目描述。

输出格式:
一行 $ n $ 个用空格隔开的整数,表示操作前锁轮上的数字。

数据范围:
$ 1 \le n,t \le 100,0 \le a_i \le 9,1 \le b_i \le 10 $

**题目描述**

Luca has a cypher made up of a sequence of $ n $ wheels, each with a digit $ a_i $ written on it. On the $ i $-th wheel, he made $ b_i $ moves. Each move is one of two types:

- up move (denoted by $ \texttt{U} $): it increases the $ i $-th digit by 1. After applying the up move on 9, it becomes 0.
- down move (denoted by $ \texttt{D} $): it decreases the $ i $-th digit by 1. After applying the down move on 0, it becomes 9.

Luca knows the final sequence of wheels and the moves for each wheel. Help him find the original sequence and crack the cypher.

**输入输出格式**

输入格式:
第一行包含一个整数 $ t $ ($ 1 \leq t \leq 100 $) —— 测试用例的数量。

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

第二行包含 $ n $ 个整数 $ a_i $ ($ 0 \leq a_i \leq 9 $) —— 所有移动完成后第 $ i $ 个锁轮上显示的数字。

然后是 $ n $ 行,第 $ i $ 行包含整数 $ b_i $ ($ 1 \leq b_i \leq 10 $) 和 $ b_i $ 个字符,这些字符要么是 $ \texttt{U} $ 要么是 $ \texttt{D} $ —— 在第 $ i $ 个锁轮上执行的移动次数和执行的移动。$ \texttt{U} $ 和 $ \texttt{D} $ 分别代表向上移动和向下移动。

输出格式:
对于每个测试用例,输出 $ 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
```

**说明**

在第一个测试用例中,我们可以证明初始序列是 $ [2,1,1] $。在这种情况下,执行了以下移动:

- 在第一个锁轮上:$ 2 \xrightarrow[\texttt{D}]{} 1 \xrightarrow[\texttt{D}]{} 0 \xrightarrow[\texttt{D}]{} 9 $。
- 在第二个锁轮上:$ 1 \xrightarrow[\texttt{U}]{} 2 \xrightarrow[\texttt{D}]{} 1 \xrightarrow[\texttt{U}]{} 2 \xrightarrow[\texttt{U}]{} 3 $。
- 在第三个锁轮上:$ 1 \xrightarrow[\texttt{D}]{} 0 \xrightarrow[\texttt{U}]{} 1 $。

最终序列是 $ [9,3,1] $,与输入相符。**题意翻译** 题目描述: 有一个有 $ n $ 个锁轮的锁,每个锁轮上写有一个数字 $ a_i $,对于第 $ i $ 个锁轮,执行了 $ b_i $ 次操作。这些操作有两种类型: - `U`:锁轮上的数字加 1,如果超过 9 则变为 0。 - `D`:锁轮上的数字减 1,如果小于 0 则变为 9。 现在给定操作后的锁轮和操作,请你还原操作前的锁轮。 输入格式: 第一行一个整数 $ t $,表示测试点内数据组数。 每组数据中第一行是一个正整数 $ n $,表示锁轮数。 下一行有 $ n $ 个整数 $ a_i $,表示每个锁轮操作后的数字。 接下来 $ a_i $ 行,第 $ i $ 行包含整数 $ b_i $ 和 $ b_i $ 个字符 `U` 或 `D`,具体含义见题目描述。 输出格式: 一行 $ n $ 个用空格隔开的整数,表示操作前锁轮上的数字。 数据范围: $ 1 \le n,t \le 100,0 \le a_i \le 9,1 \le b_i \le 10 $ **题目描述** Luca has a cypher made up of a sequence of $ n $ wheels, each with a digit $ a_i $ written on it. On the $ i $-th wheel, he made $ b_i $ moves. Each move is one of two types: - up move (denoted by $ \texttt{U} $): it increases the $ i $-th digit by 1. After applying the up move on 9, it becomes 0. - down move (denoted by $ \texttt{D} $): it decreases the $ i $-th digit by 1. After applying the down move on 0, it becomes 9. Luca knows the final sequence of wheels and the moves for each wheel. Help him find the original sequence and crack the cypher. **输入输出格式** 输入格式: 第一行包含一个整数 $ t $ ($ 1 \leq t \leq 100 $) —— 测试用例的数量。 每个测试用例的第一行包含一个整数 $ n $ ($ 1 \leq n \leq 100 $) —— 锁轮的数量。 第二行包含 $ n $ 个整数 $ a_i $ ($ 0 \leq a_i \leq 9 $) —— 所有移动完成后第 $ i $ 个锁轮上显示的数字。 然后是 $ n $ 行,第 $ i $ 行包含整数 $ b_i $ ($ 1 \leq b_i \leq 10 $) 和 $ b_i $ 个字符,这些字符要么是 $ \texttt{U} $ 要么是 $ \texttt{D} $ —— 在第 $ i $ 个锁轮上执行的移动次数和执行的移动。$ \texttt{U} $ 和 $ \texttt{D} $ 分别代表向上移动和向下移动。 输出格式: 对于每个测试用例,输出 $ 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 ``` **说明** 在第一个测试用例中,我们可以证明初始序列是 $ [2,1,1] $。在这种情况下,执行了以下移动: - 在第一个锁轮上:$ 2 \xrightarrow[\texttt{D}]{} 1 \xrightarrow[\texttt{D}]{} 0 \xrightarrow[\texttt{D}]{} 9 $。 - 在第二个锁轮上:$ 1 \xrightarrow[\texttt{U}]{} 2 \xrightarrow[\texttt{D}]{} 1 \xrightarrow[\texttt{U}]{} 2 \xrightarrow[\texttt{U}]{} 3 $。 - 在第三个锁轮上:$ 1 \xrightarrow[\texttt{D}]{} 0 \xrightarrow[\texttt{U}]{} 1 $。 最终序列是 $ [9,3,1] $,与输入相符。

加入题单

算法标签: