翻译修复
查看原帖
翻译修复
727008
lwx20211103楼主2023/8/17 15:10

Cypher

题面翻译

题目描述

有一把 nn 个锁轮的锁,每个锁轮上写有数字 aia_i ,对于第 ii 个锁轮,做了 bib_i 次操作。这些操作有两种类型:

  • U:锁轮上的数字 +1+1 ,超过 99 则变为 00 。
  • D:锁轮上的数字 −1-1 ,小于 00 则变为 99 。

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

输入格式

第一行一个整数 tt ,表示测试点内数据组数。

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

下一行有 nn 个整数 aia_i ,表示每个锁轮操作后的数字。

以下 ai\red{a_i}-> nn 行,第 ii 行包含整数 bib_i 和 bib_i 个字符 U 或 D ,含义见题目描述。

输出格式

一行 nn 个用空格隔开的整数,表示操作前锁轮上的数字。

数据范围

1≤n,t≤100,0≤ai≤9,1≤bi≤101 \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 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.

输入格式

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.

输出格式

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

样例 #1

样例输入 #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.

源码:

# Cypher

## 题面翻译

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

- `U`:锁轮上的数字 $+1$ ,超过 $9$ 则变为 $0$ 。
- `D`:锁轮上的数字 $-1$ ,小于 $0$ 则变为 $9$ 。

现在给定操作后的锁轮和操作,请你还原操作前的锁轮。
## 输入格式
第一行一个整数 $t$ ,表示测试点内数据组数。

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

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

以下 $n$ 行,第 $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

### 样例输入 #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.
2023/8/17 15:10
加载中...