474A - Keyboard - CodeForces Solution


implementation *900

Please click on ads to support us..

Python Code:

letter = input()
line = input()
keyboard = ['q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p', 'a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', ';', 'z',
            'x', 'c', 'v', 'b', 'n', 'm', ',', '.', '/']
output = ""
index = 0
if letter == 'R':
    for x in line:
        index = keyboard.index(x)
        output += keyboard[index - 1]
elif letter == 'L':
    for x in line:
        index = keyboard.index(x)
        output += keyboard[index + 1]

print(output)

C++ Code:

#include <bits/stdc++.h>
#define loop(n)      for (int i=0;i<n ;i++)
#define endl     '\n'
#define ll     long long
using namespace std;

void init()
{
    cin.tie(0);
    cin.sync_with_stdio(0);
}

int main()
{

    init() ;
    ll n,x;
    char type , c;
  map <char ,int > m ;
  string s ="qwertyuiopasdfghjkl;zxcvbnm,./" ;
  loop (s.length())
  {
     m[s[i]]=i ;
  }
  cin>> type ;
  if (type=='R')
    {

       while (cin>> c )
       {
           cout << s[m[c]-1] ;
       }
    }
    else 
    {
       while (cin>> c )
       {
           cout << s[m[c]+1] ;
       }  
    }




    return 0;
}


Comments

Submit
0 Comments
More Questions

1490B - Balanced Remainders
264A - Escape from Stones
1506A - Strange Table
456A - Laptops
855B - Marvolo Gaunt's Ring
1454A - Special Permutation
1359A - Berland Poker
459A - Pashmak and Garden
1327B - Princesses and Princes
1450F - The Struggling Contestant
1399B - Gifts Fixing
1138A - Sushi for Two
982C - Cut 'em all
931A - Friends Meeting
1594A - Consecutive Sum Riddle
1466A - Bovine Dilemma
454A - Little Pony and Crystal Mine
2A - Winner
1622B - Berland Music
1139B - Chocolates
1371A - Magical Sticks
1253A - Single Push
706B - Interesting drink
1265A - Beautiful String
214A - System of Equations
287A - IQ Test
1108A - Two distinct points
1064A - Make a triangle
1245C - Constanze's Machine
1005A - Tanya and Stairways