Codeforces Round #742 (Div. 2)

简介: Codeforces Round #742 (Div. 2)

A. Domino Disaster

time limit per test

2 seconds

memory limit per test

256 megabytes

input

standard input

output

standard output


Alice has a grid with 22 rows and nn columns. She fully covers the grid using nn dominoes of size 1×21×2 — Alice may place them vertically or horizontally, and each cell should be covered by exactly one domino.


Now, she decided to show one row of the grid to Bob. Help Bob and figure out what the other row of the grid looks like!


Input


The input consists of multiple test cases. The first line contains an integer tt (1≤t≤50001≤t≤5000) — the number of test cases. The description of the test cases follows.


The first line of each test case contains an integer nn (1≤n≤1001≤n≤100) — the width of the grid.


The second line of each test case contains a string ss consisting of nn characters, each of which is either L, R, U, or D, representing the left, right, top, or bottom half of a domino, respectively (see notes for better understanding). This string represents one of the rows of the grid.


Additional constraint on the input: each input corresponds to at least one valid tiling.


Output


For each test case, output one string — the other row of the grid, using the same format as the input string. If there are multiple answers, print any.


Example


input

Copy

4

1

U

2

LR

5

LRDLR

6

UUUUUU


output

Copy

D

LR

LRULR

DDDDDD

Note


In the first test case, Alice shows Bob the top row, the whole grid may look like


In the second test case, Alice shows Bob the bottom row, the whole grid may look like:


c39cc30375b80ea49217a9f313141eea.png

In the third test case, Alice shows Bob the bottom row, the whole grid may look like:


In the fourth test case, Alice shows Bob the top row, the whole grid may look like:


题目挺简单的,直接上代码。

 

#include <iostream>
using namespace std;
#define ll long long
char s[333];
signed main() {
  long long t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    scanf("%s", s + 1);
    for (int i = 1; i <= n; i++) {
      if (s[i] == 'U') {
        printf("D");
        continue;
      }
      if (s[i] == 'D') {
        printf("U");
        continue;
      }
      printf("%c", s[i]);
    }
    printf("\n");
  }
}


相关文章
|
2月前
|
人工智能 测试技术 BI
Codeforces Round 942 (Div. 2)
Codeforces Round 942 (Div. 2)
|
5月前
Codeforces Round #567 (Div. 2)
【7月更文挑战第1天】
48 7
|
6月前
Codeforces Round #729 (Div. 2)
【6月更文挑战第4天】在这两个编程问题中,B. Plus and Multiply 要求判断通过加法和乘法操作数组是否能形成目标数 `n`。思路是形如 `x^a + yb = n` 的表达式,如果满足则能构造。C. Strange Function 关注的是找到最小正整数 `x` 使得 `x` 不是 `i` 的因子,计算这些值的和模 `10^9+7`。对于每个 `i`,偶数时 `f(i)` 是 3,奇数时是 2,利用因子与最大公约数计算周期性求和。
35 1
Codeforces Round #186 (Div. 2)A、B、C、D、E
Ilya得到了一个礼物,可以在删掉银行账户最后和倒数第二位的数字(账户有可能是负的),也可以不做任何处理。
35 0
Codeforces Round #192 (Div. 2) (330A) A. Cakeminator
如果某一行没有草莓,就可以吃掉这一行,某一列没有也可以吃点这一列,求最多会被吃掉多少块蛋糕。
50 0
Codeforces Round 799 (Div. 4)
Codeforces Round 799 (Div. 4)
121 0
Codeforces Round 640 (Div. 4)
Codeforces Round 640 (Div. 4)A~G
96 0
Codeforces Round #675 (Div. 2) A~D
Codeforces Round #675 (Div. 2) A~D
155 0
Equidistant Vertices-树型dp-Codeforces Round #734 (Div. 3)
Description A tree is an undirected connected graph without cycles. You are given a tree of n vertices. Find the number of ways to choose exactly k vertices in this tree (i. e. a k-element subset of vertices) so that all pairwise distances between the selected vertices are equal (in other words,
141 0