-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathA_Homework.java
More file actions
33 lines (31 loc) · 942 Bytes
/
Copy pathA_Homework.java
File metadata and controls
33 lines (31 loc) · 942 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import java.util.*;
public class A_Homework {
public static void main(String[] args) {
Scanner s=new Scanner(System.in);
int t=s.nextInt();
while(t-->0){
int n=s.nextInt();
s.nextLine();
String s1=s.nextLine();
int x=s.nextInt();
s.nextLine();
String s2=s.nextLine();
String s3=s.nextLine();
StringBuilder s4=new StringBuilder();
for(int i=s3.length()-1;i>=0;i--){
if(s3.charAt(i)=='V'){
s4.append(s2.charAt(i));
}
}
for(int i=0;i<s1.length();i++){
s4.append(s1.charAt(i));
}
for(int i=0;i<s3.length();i++){
if(s3.charAt(i)=='D'){
s4.append(s2.charAt(i));
}
}
System.out.println(s4.toString());
}
}
}