Codeforces Round #806 (Div. 4) 1703C. Cypher Solution



 Problem Link: https://codeforces.com/contest/1703/problem/C

Solution in C++:

///La ilaha illellahu muhammadur rasulullah
///******Bismillahir-Rahmanir-Rahim******///
///Abul Hasnat  Tonmoy
///Department of CSE,23rd batch
///Islamic University,Bangladesh
///**********ALLAH IS ALMIGHTY************///
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long  x,v,t,i,j,o,e,n;
    cin>>t;
    while(t--)
    {
        cin>>n;
        int a[n+9],b;
        for(i=0; i<n; i++)cin>>a[i];
        for(i=0; i<n; i++)
        {
            string s;
            cin>>b>>s;
            for(j=0; j<b; j++)
            {
                if(s[j]=='D'&&a[i]==9)a[i]=0;
                else if(s[j]=='U'&&a[i]==0)a[i]=9;
                else if(s[j]=='U')a[i]--;
                else
                    a[i]++;
            }

        }
        for(i=0; i<n; i++)
        {
            cout<<a[i]<<" ";
        }
        cout<<endl;

    }
}
 
 


 

No comments

Most View Post

Recent post

Codeforces Round 925 (Div. 3) 1931D. Divisible Pairs Solution

    Problem Link  :   https://codeforces.com/contest/1931/problem/D S olution in C++: /// Author : AH_Tonmoy #include < bits / stdc ++. ...

Powered by Blogger.