10878 - Decode the tape

All about problems in Volume 108. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

Raj Ariyan
Learning poster
Posts: 70
Joined: Sat Feb 05, 2005 9:38 am
Location: Gurukul

10878 Decode the tape !!!!!!

Post by Raj Ariyan » Tue Aug 02, 2005 7:01 pm

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
Some Love Stories Live Forever ....

User avatar
Roby
Experienced poster
Posts: 101
Joined: Wed May 04, 2005 4:33 pm
Location: Tangerang, Banten, Indonesia
Contact:

10878 - Decode the tape

Post by Roby » Sat Sep 03, 2005 5:01 pm

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*

misof
A great helper
Posts: 430
Joined: Wed Jun 09, 2004 1:31 pm

Post by misof » Sat Sep 03, 2005 6:26 pm

The code are just normal ASCII values. On the first sight, your value for capital Z is wrong.

User avatar
Roby
Experienced poster
Posts: 101
Joined: Wed May 04, 2005 4:33 pm
Location: Tangerang, Banten, Indonesia
Contact:

Post by Roby » Sun Sep 04, 2005 3:10 pm

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. :)

User avatar
Cho
A great helper
Posts: 274
Joined: Wed Oct 20, 2004 11:51 pm
Location: Hong Kong

Post by Cho » Sun Sep 04, 2005 3:26 pm

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'.

mamun
A great helper
Posts: 286
Joined: Mon Oct 03, 2005 1:54 pm
Location: Bangladesh
Contact:

Post by mamun » Fri Oct 14, 2005 12:53 am

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!

jjtse
Learning poster
Posts: 80
Joined: Mon Aug 22, 2005 7:32 pm
Location: Nevada, US
Contact:

Post by jjtse » Fri Dec 09, 2005 10:31 pm

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

User avatar
Martin Macko
A great helper
Posts: 481
Joined: Sun Jun 19, 2005 1:18 am
Location: European Union (Slovak Republic)

Post by Martin Macko » Sat Dec 10, 2005 3:59 pm

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.

vinit_iiita
New poster
Posts: 30
Joined: Mon Jun 19, 2006 10:37 pm
Contact:

Post by vinit_iiita » Wed Aug 23, 2006 11:26 pm

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]
Last edited by vinit_iiita on Thu Aug 24, 2006 10:16 am, edited 1 time in total.
win

User avatar
Martin Macko
A great helper
Posts: 481
Joined: Sun Jun 19, 2005 1:18 am
Location: European Union (Slovak Republic)

Post by Martin Macko » Thu Aug 24, 2006 12:07 am

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.

vinit_iiita
New poster
Posts: 30
Joined: Mon Jun 19, 2006 10:37 pm
Contact:

Post by vinit_iiita » Thu Aug 24, 2006 12:09 am

hi plz tell me how can i avoid that. i could not figure out how...
win

vinit_iiita
New poster
Posts: 30
Joined: Mon Jun 19, 2006 10:37 pm
Contact:

Post by vinit_iiita » Thu Aug 24, 2006 12:12 am

i would like to know its elobaration...
win

User avatar
Martin Macko
A great helper
Posts: 481
Joined: Sun Jun 19, 2005 1:18 am
Location: European Union (Slovak Republic)

Post by Martin Macko » Thu Aug 24, 2006 5:51 am

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.

vinit_iiita
New poster
Posts: 30
Joined: Mon Jun 19, 2006 10:37 pm
Contact:

Post by vinit_iiita » Thu Aug 24, 2006 10:12 am

thanks a lot martin...i got ac now...
win

rafi6047
New poster
Posts: 3
Joined: Tue Oct 10, 2006 5:02 pm

10878 pls help

Post by rafi6047 » Wed Oct 11, 2006 7:56 am

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;
}

Post Reply

Return to “Volume 108 (10800-10899)”