-
Notifications
You must be signed in to change notification settings - Fork 501
Expand file tree
/
Copy path(CODEFORCES)1703C.cpp
More file actions
79 lines (61 loc) · 1.2 KB
/
(CODEFORCES)1703C.cpp
File metadata and controls
79 lines (61 loc) · 1.2 KB
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#include <bits/stdc++.h>
using namespace std;
const char nl = '\n';
const char space = ' ';
typedef long long ll;
#define MOD 1000000007
void solve()
{
int n;
cin>>n;
int a[n];
for(int i=0;i<n;i++) cin>>a[i];
int k=0;
while(k<n)
{
int p;
cin>>p;
char u[p];
for(int i=0;i<p;i++){ cin>>u[i];}
for(int i=p-1;i>=0;i--)
{
if(u[i]=='U')
{
if(a[k]==0) {a[k]=9;}
else
{
a[k]--;
}
}
else
{
if(a[k]==9) {a[k]=0;}
else
{
a[k]++;
}
}
}
k++;
}
for(int i=0;i<n;i++) cout<<a[i]<<space;
cout<<nl;
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
int T=1;
cin >> T;
for(int tc = 1; tc <= T; tc++)
{
//cout << "Case #" << tc << ": ";
solve();
}
return 0;
}