本场比赛其他题目的题解

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 222 rows and nnn columns. She fully covers the grid using nnn dominoes of size 1×21 \times 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 ttt (1≤t≤50001 \leq t \leq 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 nnn (1≤n≤1001 \leq n \leq 1001≤n≤100) — the width of the grid.

The second line of each test case contains a string sss consisting of nnn 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:

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

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:

题意

一个 2×n2 \times n2×n 的方格,只能放 1×21 \times 21×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;
}

codeforces 1567 A. Domino Disaster相关推荐

  1. codeforces 1567 C. Carrying Conundrum

    本场比赛其他题目的题解 A. Domino Disaster B. MEXor Mixup C. Carrying Conundrum D. Expression Evaluation Error E ...

  2. codeforces 1567 B. MEXor Mixup

    本场比赛其他题目的题解 A. Domino Disaster B. MEXor Mixup C. Carrying Conundrum D. Expression Evaluation Error E ...

  3. codeforces 1567 E. Non-Decreasing Dilemma

    本场比赛其他题目的题解 A. Domino Disaster B. MEXor Mixup C. Carrying Conundrum D. Expression Evaluation Error E ...

  4. codeforces:ProblemMset

    最近一个月在codeforces上做的题(做个记录) 后面太多了就不把代码一一放出了,只放置了链接,可根据链接找到提交的代码. 最小子矩阵 #include <iostream> #inc ...

  5. Codeforces Round #742 (Div. 2) 个人题解

    A. Domino Disaster 2分钟签到 #include <bits/stdc++.h> #define fors(i, a, b) for(int i = (a); i < ...

  6. Codeforces Round #742 (Div. 2)

    题目 题解链接 难度 主要算法 A. Domino Disaster A. Domino Disaster 800 模拟 B. MEXor Mixup B. MEXor Mixup 1000 思维 C ...

  7. CF杂题训练(交互题不做,2500以上的看情况吧)

    CF专练 CF1562 A The Miracle and the Sleeper B Scenes From a Memory C Rings D Two Hundred Twenty One E ...

  8. Codeforces Round #609 (Div. 2) D. Domino for Young 黑白染色

    传送门 文章目录 题意: 思路: 题意: 给你个不规则的网络格子,有nnn列,每列有aia_iai​个格子,让你将1×21×21×2的多米诺骨牌无重叠的放进去,问最多能放多少个. 思路: 首先如果点数 ...

  9. Educational Codeforces Round 106 (Rated for Div. 2)(A ~ E)题解(每日训练 Day.16 )

    整理的算法模板合集: ACM模板 点我看算法全家桶系列!!! 实际上是一个全新的精炼模板整合计划 目录 Educational Codeforces Round 106 (Rated for Div. ...

最新文章

  1. 【maven】修改编译得到的文件名
  2. [Python图像处理] 二十三.傅里叶变换之高通滤波和低通滤波
  3. 虚拟机系统与宿主机共享上网设置
  4. 数据库-数据库设计原则-范式概念
  5. [Vue warn]: Duplicate keys detected: ‘0‘. This may cause an update error.
  6. SQLServer、Mysql、Oracle 创建、删除用户和授予用户权限
  7. UVA 10004 - Bicoloring
  8. 学java要学vue吗_学vue之前必看
  9. 翻译|How to Export a Connected Component
  10. c语言sizeof输出单位,急,求大神!C语言中sizeof问题
  11. for linux pdf转mobi_下载安装Calibre在Linux CLI中将ePub文件转换为PDF格式
  12. java rx3x_GitHub - xkm123/oss-sdk-java: java sdk for oss
  13. 计算机考证上传照片说明
  14. java计算机毕业设计东理咨询交流论坛源码+系统+lw文档+mysql数据库+部署
  15. 【Pytorch深度学习实践】B站up刘二大人课程笔记——目录与索引(已完结)
  16. 使用Python编写程序,输入一个大于 2 的自然数,然后输出小于该数字的所有素数组成的集合。
  17. 中国食物链?(看不上,看不起,瞧不起,狗眼看人低)
  18. 【c++入门(2)】关联容器map
  19. MULE DW Function 使用expression transformer解析嵌套MEL
  20. 安卓来电归属地_苹果手机 VS 安卓手机

热门文章

  1. 关于火车运煤的一些想法
  2. MySQL数据库实操教程(25)——权限管理
  3. 襄阳教育云平台实名认证_襄阳教育云平台登录入口-襄阳教育云平台2020最新学习app4.1.6下载_飞翔下载...
  4. 微信支付api_key
  5. antD布局不能占满屏幕问题
  6. 第一届嵌入式电子竞赛方案设计——智能门禁系统
  7. 关于高通平台下camera一些参数的设置
  8. math_(函数数列)极限的含义误区和符号梳理/邻域去心邻域邻域半径
  9. 智能车八邻域图像算法_二
  10. C#WebApi下载文件