-
Notifications
You must be signed in to change notification settings - Fork 0
/
Cypher.cpp
51 lines (49 loc) · 937 Bytes
/
Cypher.cpp
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
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
ll t;
cin>>t;
while(t--)
{
ll n;
cin>>n;
ll a[n],b[n];
string s[n];
for(ll i=0;i<n;i++)
{
cin>>a[i];
}
for(ll i=0;i<n;i++)
{
cin>>b[i]>>s[i];
}
for(ll i=0;i<n;i++)
{
for(ll j=0;j<b[i];j++)
{
if(s[i][j]=='D')
{
a[i]++;
if(a[i]>9)
a[i]=0;
}
else
{
a[i]--;
if(a[i]<0)
a[i]=9;
}
}
}
for(ll i=0;i<n;i++)
{
cout<<a[i]<<" ";
}
cout<<endl;
}
return 0;
}