标签:case Disaster Domino codeforces Alice grid each test row
本场比赛其他题目的题解
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:
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 × 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;
}
标签:case,Disaster,Domino,codeforces,Alice,grid,each,test,row 来源: https://blog.csdn.net/mengzhongsharen/article/details/120273023
本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享; 2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关; 3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关; 4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除; 5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。