codeforces 1567 A. Domino Disaster

本场比赛其他题目的题解

A. Domino Disaster
B. MEXor Mixup
C. Carrying Conundrum
D. Expression Evaluation Error
E. Non-Decreasing Dilemma

A. Domino Disaster

开启传送门

题目描述

Alice has a grid with 2 2 2 rows and n n n columns. She fully covers the grid using n n n dominoes of size 1 × 2 1 \times 2 1×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 t t t ( 1 ≤ t ≤ 5000 1 \leq t \leq 5000 1≤t≤5000) — the number of test cases. The description of the test cases follows.

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

The second line of each test case contains a string s s s consisting of n n n 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

Input1

4
1
U
2
LR
5
LRDLR
6
UUUUUU

Output1

D
LR
LRULR
DDDDDD

Note

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

codeforces 1567 A. Domino Disaster

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

codeforces 1567 A. Domino Disaster

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

codeforces 1567 A. Domino Disaster

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

codeforces 1567 A. Domino Disaster

题意

一个 2 × n 2 \times n 2×n 的方格,只能放 1 × 2 1 \times 2 1×2 的多米罗骨牌,保证密铺的情况下,给出第一行的情况,输出第二行的情况。

分析

模拟一下就行了,可以发现第一行可以决定第二行的样式,所以直接输出相应的字符就行了。

#include<bits/stdc++.h>
using namespace std;
int len;
string a;
void solve() {
	cin>>len>>a;
	for(int i = 0;i<len;i++) {
		if(a[i] == 'U' || a[i] == 'D') cout<<char('U' - a[i] + 'D');
		else cout<<a[i];
	}
	cout<<endl;
}
int main() {
	int t;
	cin>>t;
	while(t--) solve();
	return 0;
}
上一篇:Object类—复写equals方法,hashCode方法,toString方法


下一篇:Jquery 网页转换为图片