Page 1 of 3

10222 - Decode the Mad man

Posted: Sat Jan 11, 2003 1:55 am
by amd-RS
Hi all,

What should be the answer for the input:

qwaszx

Thanks a lot !!!

Posted: Sun Jan 12, 2003 2:55 pm
by Jalal
outputs:
{};`./

Posted: Tue Jan 14, 2003 12:06 am
by amd-RS
Jalal wrote:outputs:
{};`./
Thanks, I got accepted now :D

Aur

Problem with scanf...

Posted: Sun Nov 16, 2003 9:03 am
by Isilio
Hi brothers!!!
How can i know the end of line, in a file that have words separated by a blank space...

Example of a file:

asdasd asdasdasd asdasdasd
asd 3re34 trtet 3ldsd elekwr

Posted: Sun Nov 16, 2003 6:55 pm
by deddy one
you can use gets to get one line and then tokenize it

ex :
[c]char line[100];
gets (line);

for (int i=0;line!='\0';i++)
if (line==' ') {
//if it's space do something....
}
else {
// do something else....
}
[/c]

another way is to use strtok.

just curious, are you trying to solve 494??

Thanx

Posted: Mon Nov 17, 2003 6:24 am
by Isilio
I got accepted!!!

no 10222....

10222 -WA

Posted: Sat Dec 27, 2003 8:22 pm
by snake
Hy! I just can't get rid of that WA. Does anyone know what's wrong with the code?!

Thanks!

[cpp]

#include <iostream>
#include <ctype.h>
using namespace std;

char change(char ch)
{
ch = tolower(ch);
switch(ch)
{
case '}':
return 'p';
case '{':
return 'o';
case 'p':
return 'i';
case 'o':
return 'u';
case 'i':
return 'y';
case 'u':
return 't';
case 'y':
return 'r';
case 't':
return 'e';
case 'r':
return 'w';
case 'e':
return 'q';
case 'w':
return '}';
case 'q':
return '{';
case '`':
return 'l';
case ';':
return 'k';
case 'l':
return 'j';
case 'k':
return 'h';
case 'j':
return 'g';
case 'h':
return 'f';
case 'g':
return 'd';
case 'f':
return 's';
case 'd':
return 'a';
case 's':
return '`';
case 'a':
return ';';
case '/':
return ',';
case '.':
return 'm';
case ',':
return 'n';
case 'm':
return 'b';
case 'n':
return 'v';
case 'b':
return 'c';
case 'v':
return 'x';
case 'c':
return 'z';
case 'x':
return '/';
case 'z':
return '.';
}



}
void main()
{
char line[1000];
int n=0;
char out[1000] ={0};
while(cin.getline(line, 1000))
{
for(int n=0;n<1000;n++)
out[n] = 0;
for(int i=0;i<strlen(line);i++)
{
out = change(line);
}
cout << out << endl;
}

}[/cpp]

10222

Posted: Sat Dec 27, 2003 8:54 pm
by osan
i couldn't get the problem yet.
but do u consider \n??
& check the keyboard that u r not missing any key.
ok?

Posted: Sat Dec 27, 2003 9:06 pm
by snake
What do you mean \n? Is it special in any way?

I think the problem might be that I don't have the US keyboard, and the position of the keys are a bit mixed up.

Am I missing the numbers. I don't know, I can't see that the numbers must also be implemented.

qwaszx outputs {};`./
I found that this is correct (few pages back on this forums).

PS. Do I have to treat shift keys aswell? ([] instead of {} and so)?

10222 - invalid memory reference?? what the...

Posted: Sat Mar 13, 2004 1:49 pm
by keceman
anything wrong with my code?? i got runtime error: invalid memory reference... what's wrong??

/* @JUDGE_ID: 43238WF 10222 C++ */

#include <iostream.h>

int map_row1[12] = {113,119,101,114,116,121,117,105,111,112,91,93};
int map_row2[11] = {97,115,100,102,103,104,106,107,108,59,39};
int map_row3[9] = {122,120,99,118,98,110,109,44,46};

void convertBigChar(char* text)
{
int x=0;
while (text[x] != '\0')
{
if ((text[x] >= 65) && (text[x] <= 90))
{
text[x]=text[x]+32;
}
else if (text[x] == 123) text[x]=91;
else if (text[x] == 125) text[x]=93;
else if (text[x] == 34) text[x]=39;
else if (text[x] == 58) text[x]=59;
else if (text[x] == 62) text[x]=44;
else if (text[x] == 60) text[x]=46;
x++;
}
}

void process(char* text)
{
int x=0,y;
while (text[x] != '\0')
{
for (y=0;y<12;y++) // map_row 1
{
if (text[x] == map_row1[y])
{
text[x]=map_row1[y-2];
break;
}
}
for (y=0;y<11;y++) // map_row 2
{
if (text[x] == map_row2[y])
{
text[x]=map_row2[y-2];
break;
}
}
for (y=0;y<9;y++) // map_row 3
{
if (text[x] == map_row3[y])
{
text[x]=map_row3[y-2];
break;
}
}
x++;
}
}

void main()
{
char a;
char *text;
int x, length;
while ((cin != 0))
{
text = new char [32];
x = 0;
a = cin.get();
while (a != '\n')
{
text[x]=a;
x++;
a=cin.get();
}
length=x;
text[x]='\0';
convertBigChar(text);
process(text);
cout << text << endl;
delete [] text;
}
}

Posted: Sat Mar 13, 2004 3:08 pm
by alu_mathics
i made the followung changes.Its ok now.If u got ac inform me.
#include <iostream.h>
#include <stdio.h>

int map_row1[12] = {113,119,101,114,116,121,117,105,111,112,91,93};
int map_row2[11] = {97,115,100,102,103,104,106,107,108,59,39};
int map_row3[9] = {122,120,99,118,98,110,109,44,46};

void convertBigChar(char* text)
{
int x=0;
while (text[x] != '\0')
{
if ((text[x] >= 65) && (text[x] <= 90))
{
text[x]=text[x]+32;
}
else if (text[x] == 123) text[x]=91;
else if (text[x] == 125) text[x]=93;
else if (text[x] == 34) text[x]=39;
else if (text[x] == 5) text[x]=59;
else if (text[x] == 62) text[x]=44;
else if (text[x] == 60) text[x]=46;
x++;
}
}

void process(char* text)
{
int x=0,y;
while (text[x] != '\0')
{
for (y=0;y<12;y++) // map_row 1
{
if (text[x] == map_row1[y])
{
text[x]=map_row1[y-2];
break;
}
}
for (y=0;y<11;y++) // map_row 2
{
if (text[x] == map_row2[y])
{
text[x]=map_row2[y-2];
break;
}
}
for (y=0;y<9;y++) // map_row 3
{
if (text[x] == map_row3[y])
{
text[x]=map_row3[y-2];
break;
}
}
x++;
}
}

void main()
{
char a;
char *text;
int x, length;
while (1)//(cin != 0))
{
text = new char [100000];
x = 0;
a = cin.get();
if(feof(stdin))break;
while (a != '\n')
{
text[x]=a;
x++;
a=cin.get();
}
length=x;
text[x]='\0';
convertBigChar(text);
process(text);
cout << text << endl;
//delete [] text;
}
}

About input.

Posted: Thu Apr 15, 2004 5:48 am
by _.B._
Greetings!.
For this problem I considered only these characters, and the "space bar", as valid input:

Code: Select all

ertyuiop[]dfghjkl;'cvbnm,.
Hope it helps.

10222 WA ..WHY!!

Posted: Sun Sep 05, 2004 11:33 pm
by midra
Maybe because I have an spanish keyboard, but I think I make a correct intialization of the keys.
I get WA over and over again.
here is my code:

[c]
#include <stdio.h>

int main()
{
char a[100000];
char C[47]={"{}qwertyuiop[];

10222 Why P.E

Posted: Sat Sep 25, 2004 10:22 am
by efr_shovo
/* Why This Gives P.E Pleaze Help


#include<stdio.h>
#define MAX 300
char kb[MAX];
char str[10000];
int i;
void main()
{
kb['e']='q';
kb['r']='w';
kb['t']='e';
kb['y']='r';

kb['u']='t';
kb['i']='y';
kb['o']='u';
kb['p']='i';
kb['[']='o';

kb[']']='p';
kb['\\']='[';



kb['2']='`';
kb['3']='1';
kb['4']='2';
kb['5']='3';

kb['6']='4';
kb['7']='5';
kb['8']='6';
kb['9']='7';
kb['0']='8';

kb['-']='9';
kb['=']='0';
kb['=']='0';



kb['d']='a';
kb['f']='s';
kb['g']='d';
kb['h']='f';

kb['j']='g';
kb['k']='h';
kb['l']='j';
kb[';']='k';
kb['\'']='l';

kb['\\']=';';



kb['c']='z';
kb['v']='x';
kb['b']='c';
kb['n']='v';

kb['m']='b';
kb[',']='n';
kb['.']='m';
kb['/']=',';
while(gets(str))
{
while(str)
{
if(kb[str]=='\0')
putchar(str[i++]);
else
putchar(kb[str[i++]]);
}
i=0;
}
}

Posted: Sat Oct 16, 2004 4:33 pm
by Qbens
1. Change this:

Code: Select all

case '}':
      return 'p';
   case '{':
      return 'o';
for this:

Code: Select all

case ']':
      return 'p';
   case '[':
      return 'o';
2.Add this to function switch

Code: Select all

case ' ':
      return ' ';
Let my know you get AC