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月前
|
人工智能 自然语言处理 数据可视化
阿里云JVS Claw是干什么的,有哪些特点和优势?
JVS Claw(“龙虾”)是基于OpenClaw深度定制的云端AI智能体平台,2026年3月上线。开箱即用、手机可控,提供独立ClawSpace(6核CPU/12GB内存),支持自然语言驱动任务、可视化执行、自进化技能及云+本地双模式。新用户享7天免费试用。(239字)
阿里云JVS Claw是干什么的,有哪些特点和优势?
|
运维 前端开发 数据可视化
【CodeBuddy】一句话开发一个完整项目之:响应式栅格布局生成器
本项目是一款基于原生HTML/CSS/JavaScript的可视化栅格生成器,旨在提升响应式网页布局开发效率。通过动态调整列数、间距及颜色等参数,实时预览布局效果并生成可复用CSS代码。核心功能包括动态栅格控制、样式同步与代码生成,解决多输入控件同步、跨浏览器兼容等问题。适用于教学演示、原型设计和主题定制等场景。未来计划支持断点配置与SCSS导出,进一步优化用户体验。项目实践了CSS变量、原生API交互等技术,强调“所见即所得”原则,降低用户认知成本。
293 0
【CodeBuddy】一句话开发一个完整项目之:响应式栅格布局生成器
|
消息中间件 监控 Java
一款开源的 Kafka 管理平台
Apache Kafka UI 是一个免费的开源 Web UI,用于监控和管理 Apache Kafka 集群,可方便地查看 Kafka Brokers、Topics、消息、Consumer 等情况,支持多集群管理、性能监控、访问控制等功能
|
11月前
|
数据采集 API Python
全球电商平台商品搜索聚合接口开发实战
本文介绍了一个统一API接口的设计与实现,用于同时获取1688、淘宝和京东三大平台的商品数据。接口支持关键词搜索、分页参数及多平台结果聚合排序,提供Python调用示例,并说明了关键参数和注意事项,包括权限申请、频率限制和数据清洗建议。
|
人工智能 自然语言处理 NoSQL
Transformers 4.37 中文文档(四十九)(1)
Transformers 4.37 中文文档(四十九)
393 2
|
监控 Shell Linux
Linux的Shell脚本详解
Linux的Shell脚本详解
|
程序员 Python
Python continue 语句
Python continue 语句
646 2
|
前端开发 容器
揭秘Web前端布局秘籍:浮动,那个让你又爱又恨的布局神器,你真的了解它吗?
【8月更文挑战第23天】在Web前端设计中,浮动是一种关键布局技术,能让元素在文档流中灵活移动,实现文本环绕图片、多列布局等效果。元素通过CSS的 `float` 属性脱离正常文档流并移动到容器边缘,后续非浮动内容则围绕该元素排列。浮动可用于多列布局、导航菜单及图文混排。需注意清除浮动以避免布局问题,并处理可能导致的父元素高度塌陷。
468 0
|
存储 Kubernetes jenkins
在k8S中,Jenkins发布详细流程是什么?
在k8S中,Jenkins发布详细流程是什么?
|
网络协议 数据库 网络架构
华为路由器如何过滤OSPF 特定的3类LSA?
华为路由器如何过滤OSPF 特定的3类LSA?
548 0