Page 1 of 2

10878 Decode the tape !!!!!!

Posted: Tue Aug 02, 2005 7:01 pm
by Raj Ariyan
Hi all,
Though this is one of the very easy problem in the last contest and many ppl solved this problem during the contest, but i think the input description should be clear. Before i solved this problem , i assume that always input will be given by this way(given input), but assuming is not always good for problem solving. There is no statement that the tape is always given within a frame. I dont have any complain to Abednego. Even I want to thank him for arranged this type(math) of contest and some of good problems(D,F...). . I'm always like his problems(Graph..). :D

10878 - Decode the tape

Posted: Sat Sep 03, 2005 5:01 pm
by Roby
Can someone reply me how's the "morse code" would be? Here's my discovery for that problem, is it right or is there something missing?

Code: Select all

a  00**.**0    A  0***.**0
b  00**.*0*    B  0***.*0*
c  00**.*00    C  0***.*00
d  00**.0**    D  0***.0**
e  00**.0*0    E  0***.0*0
f  00**.00*    F  0***.00*
g  00**.000    G  0***.000

h  00*0.***    H  0**0.***
i  00*0.**0    I  0**0.**0
j  00*0.*0*    J  0**0.*0*
k  00*0.*00    K  0**0.*00
l  00*0.0**    L  0**0.0**
m  00*0.0*0    M  0**0.0*0
n  00*0.00*    N  0**0.00*
o  00*0.000    O  0**0.000

p  000*.***    P  0*0*.***
q  000*.**0    Q  0*0*.**0
r  000*.*0*    R  0*0*.*0*
s  000*.*00    S  0*0*.*00
t  000*.0**    T  0*0*.0**
u  000*.0*0    U  0*0*.0*0
v  000*.00*    V  0*0*.00*
w  000*.000    W  0*0*.000

x  0000.***    X  0*00.***
y  0000.**0    Y  0*00.**0
z  0000.*0*    Z  0000.*0*

_  *0**.***
.  *0*0.00*
\n ***0.*0*

Posted: Sat Sep 03, 2005 6:26 pm
by misof
The code are just normal ASCII values. On the first sight, your value for capital Z is wrong.

Posted: Sun Sep 04, 2005 3:10 pm
by Roby
how to know and convert the ASCII value to tape's "morse" code? I really don't understand. Those are my guessing only especially for the quotation and upper case letters.

About the Z, I've typed mistake. thanks for your help. :)

Posted: Sun Sep 04, 2005 3:26 pm
by Cho
There is nothing related to morse code.
Ignore the columns of '|' and '.' There is eight characters in each row. They form a 8-bit code. 'o' is 1 and space is 0. So the first row of the sample means 01000001 which is 65 and it is the ascii value of 'A'.

Posted: Fri Oct 14, 2005 12:53 am
by mamun
Cho wrote:There is nothing related to morse code.
Ignore the columns of '|' and '.' There is eight characters in each row. They form a 8-bit code. 'o' is 1 and space is 0. So the first row of the sample means 01000001 which is 65 and it is the ascii value of 'A'.
Thanks to Cho. Without any explanation of the code in the problem, it was almost meaningless!

Posted: Fri Dec 09, 2005 10:31 pm
by jjtse
Hey Guys,

I'm so stumped. I bet you the reason my program is getting WA is because I'm using something that isn't available in the judge's version of the compiler.

I ran this, and it works fine. I even modified my codes to ignore '|' and '.', just in case they stuck them in there. Can anyone see what's wrong with my codes?:

Code: Select all


#include <iostream>
#include <string>

using namespace std;

int binToI(string s){
  int i;
  int value = 0;
  int n = 128;

  for (i=0; i<s.length(); i++)
    {
      while (s[i] == '|' || s[i] == '.')
        i++;
      if (s[i] == 'o'){
        value = value + n;
      }
      n=n/2;
    }

  return value;
}


int main(){

  int i;
  char c;
  int val;
  string s;


  getline(cin, s);
  while (!cin.eof()){
    val = binToI(s);
    c = (char)val;
    cout<<c;
    getline(cin, s);
  }

  return 0;
}


Thanks

Posted: Sat Dec 10, 2005 3:59 pm
by Martin Macko
jjtse wrote:Hey Guys,

I'm so stumped. I bet you the reason my program is getting WA is because I'm using something that isn't available in the judge's version of the compiler.

I ran this, and it works fine. I even modified my codes to ignore '|' and '.', just in case they stuck them in there. Can anyone see what's wrong with my codes?:
The input begins with line "___________" that your method decodes to 0. You shouldn't write this 0 to the output.

Posted: Wed Aug 23, 2006 11:26 pm
by vinit_iiita

Code: Select all

code removed after AC 
plz give the test cases for which it is incorret or point out mistakes...
plz help me out...[/b]

Posted: Thu Aug 24, 2006 12:07 am
by Martin Macko
vinit_iiita wrote:plz give the test cases for which it is incorret or point out mistakes...
plz help me out...
You output garbage (namely ASCII 0x00) after the last character.

Posted: Thu Aug 24, 2006 12:09 am
by vinit_iiita
hi plz tell me how can i avoid that. i could not figure out how...

Posted: Thu Aug 24, 2006 12:12 am
by vinit_iiita
i would like to know its elobaration...

Posted: Thu Aug 24, 2006 5:51 am
by Martin Macko
vinit_iiita wrote:hi plz tell me how can i avoid that. i could not figure out how...
You are getting the ASCII symbol 0x00 from the last input line '___________'. Make sure, your program doesn't try to translate this line.

Posted: Thu Aug 24, 2006 10:12 am
by vinit_iiita
thanks a lot martin...i got ac now...

10878 pls help

Posted: Wed Oct 11, 2006 7:56 am
by rafi6047
pls help me. i dont know y im getting WA. this is my code:


#include<iostream.h>
#include<stdio.h>
#include<string.h>

int main()
{
char start[20],end[20], middle[1000][20];
int i,j,k,l;

while(gets(start))
{

i=0;

while(gets(middle[i++]))
{
if(!strcmp("| o. o |",middle[i-1])) break;
}

gets(end);

for(j=0;j<i;j++)
{

if(!strcmp(middle[j],"| oo . o|")) cout<<"a";
else if(!strcmp(middle[j],"| o . o|")) cout<<"A";
else if(!strcmp(middle[j],"| o . |")) cout<<" ";

else if(!strcmp(middle[j],"| ooo . o|")) cout<<"q";
else if(!strcmp(middle[j],"| o o . o|")) cout<<"Q";
else if(!strcmp(middle[j],"| ooo .o o|")) cout<<"u";
else if(!strcmp(middle[j],"| o o .o o|")) cout<<"U";
else if(!strcmp(middle[j],"| oo o. o|")) cout<<"i";
else if(!strcmp(middle[j],"| o o. o|")) cout<<"I";
else if(!strcmp(middle[j],"| oo . oo|")) cout<<"c";
else if(!strcmp(middle[j],"| o . oo|")) cout<<"C";
else if(!strcmp(middle[j],"| oo o. oo|")) cout<<"k";
else if(!strcmp(middle[j],"| o o. oo|")) cout<<"K";

else if(!strcmp(middle[j],"| oo . o |")) cout<<"b";
else if(!strcmp(middle[j],"| o . o |")) cout<<"B";
else if(!strcmp(middle[j],"| ooo . o |")) cout<<"r";
else if(!strcmp(middle[j],"| o o . o |")) cout<<"R";
else if(!strcmp(middle[j],"| oo o.ooo|")) cout<<"o";
else if(!strcmp(middle[j],"| o o.ooo|")) cout<<"O";
else if(!strcmp(middle[j],"| ooo .ooo|")) cout<<"w";
else if(!strcmp(middle[j],"| o o .ooo|")) cout<<"W";
else if(!strcmp(middle[j],"| oo o.oo |")) cout<<"n";
else if(!strcmp(middle[j],"| o o.oo |")) cout<<"N";

else if(!strcmp(middle[j],"| oo .oo |")) cout<<"f";
else if(!strcmp(middle[j],"| o .oo |")) cout<<"F";
else if(!strcmp(middle[j],"| oooo. |")) cout<<"x";
else if(!strcmp(middle[j],"| o oo. |")) cout<<"X";

else if(!strcmp(middle[j],"| oo o. o |")) cout<<"j";
else if(!strcmp(middle[j],"| o o. o |")) cout<<"J";
else if(!strcmp(middle[j],"| ooo .o o|")) cout<<"u";
else if(!strcmp(middle[j],"| o o .o o|")) cout<<"U";
else if(!strcmp(middle[j],"| oo o.o o|")) cout<<"m";
else if(!strcmp(middle[j],"| o o.o o|")) cout<<"M";
else if(!strcmp(middle[j],"| ooo . |")) cout<<"p";
else if(!strcmp(middle[j],"| o o . |")) cout<<"P";
else if(!strcmp(middle[j],"| ooo . oo|")) cout<<"s";
else if(!strcmp(middle[j],"| o o . oo|")) cout<<"S";


else if(!strcmp(middle[j],"| ooo .oo |")) cout<<"v";
else if(!strcmp(middle[j],"| o o .oo |")) cout<<"V";
else if(!strcmp(middle[j],"| oo .o o|")) cout<<"e";
else if(!strcmp(middle[j],"| o .o o|")) cout<<"E";
else if(!strcmp(middle[j],"| ooo . o |")) cout<<"r";
else if(!strcmp(middle[j],"| o o . o |")) cout<<"R";

else if(!strcmp(middle[j],"| ooo .o |")) cout<<"t";
else if(!strcmp(middle[j],"| o o .o |")) cout<<"T";
else if(!strcmp(middle[j],"| oo o. |")) cout<<"h";
else if(!strcmp(middle[j],"| o o. |")) cout<<"H";


else if(!strcmp(middle[j],"| oo o.o |")) cout<<"l";
else if(!strcmp(middle[j],"| o o.o |")) cout<<"L";
else if(!strcmp(middle[j],"| oooo. o |")) cout<<"z";
else if(!strcmp(middle[j],"| o oo. o |")) cout<<"Z";
else if(!strcmp(middle[j],"| oooo. o|")) cout<<"y";
else if(!strcmp(middle[j],"| o oo. o|")) cout<<"Y";

else if(!strcmp(middle[j],"| oo .o |")) cout<<"d";
else if(!strcmp(middle[j],"| o .o |")) cout<<"D";
else if(!strcmp(middle[j],"| oo .ooo|")) cout<<"g";
else if(!strcmp(middle[j],"| o .ooo|")) cout<<"G";
else if(!strcmp(middle[j],"| o o.oo |")) cout<<".";
else if(!strcmp(middle[j],"| o.oo |")) cout<<",";
else if(!strcmp(middle[j],"| o. o |")) cout<<"\n";



}

}

return 0;
}