-
Notifications
You must be signed in to change notification settings - Fork 0
/
cf_round806_div4_C.java
58 lines (52 loc) · 1.57 KB
/
cf_round806_div4_C.java
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import java.util.*;
public class cf_round806_div4_C {
static class Pair{
int x;
String y;
Pair(int x, String y){
this.x = x;
this.y = y;
}
}
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
while(t --> 0){
List<Integer> res = new ArrayList<>();
int n = sc.nextInt();
int[] a = new int[n];
for(int i = 0;i<n;i++){
a[i] = sc.nextInt();
}
List<Pair> list = new ArrayList<>();
for(int i = 0;i<n;i++){
int b = sc.nextInt();
String pattern = sc.next();
list.add(new Pair(b, pattern));
}
int ind = 0;
for(Pair p : list){
int times = p.x;
String s = p.y;
for(int i = 0;i<times;i++){
if(s.charAt(i) == 'U'){
if(a[ind] == 0){
a[ind] = 10 - a[ind] - 1;
}
else{
a[ind] = a[ind] - 1;
}
}
else{
a[ind] = (a[ind] + 1)%10;
}
}
res.add(a[ind++]);
}
for(int p : res){
System.out.print(p+" ");
}
System.out.println();
}
}
}