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..).
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*
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.
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'.
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!
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?:
#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;
}
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.
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";