Input:
Code: Select all
1
.-.b.-.bb.-.
Correct Output:
Code: Select all
Message #1
RR R
Your Code Output:
Code: Select all
Message #1
R R R
Moderator: Board moderators
Code: Select all
1
.-.b.-.bb.-.
Code: Select all
Message #1
RR R
Code: Select all
Message #1
R R R
Code: Select all
Message #1
R R R
hamedv wrote:try this :
Input:
Note : b = blank ' 'Code: Select all
1 .-.b.-.bb.-.
Correct Output:
Code: Select all
Message #1 RR R
Your Code Output:Code: Select all
Message #1 R R R
Code: Select all
removed (get AC)
Code: Select all
4
.---b
.---bb
.--- --- -... -.. --- -. . ..--.. ..-. .. -. . -.-.--
.---
I think there is no input like these!!sapnil wrote:I remove extra space till get WR.
what is the output for this input:::
4
ssss.ssss.sss
ssss.ssss.
.sssssssss.
sssssssss.
Note:'s' means sigale space
Thanks..... Keep posting
sapnil.
so you don't need to count any starting and ending spaces.code between two letters is a simple silence, the code between two words is a double silence.
So No input like these:
.sss. or .ssss.
The ans is3
.- -... -.-. -.. . ..-. --. .... .. .--- -.- .-.. -- -. --- .--. --.- .-. ...- ..- ...- .-- -..- -.-- --..
.---- ..--- ...-- ....- ..... -.... --... ---.. ----. -----
.-.-.- .----. -.--. ---... .-.-. .-..-. -....- -.-.-- -.--.- -.-.-. -....- .--.-. ..--.. -..-. .-... -...- ..--.-
This tese case include all charactors the problem give us.Message #1
ABCDEFGHIJKLMNOPQRVUVWXYZ
Message #2
1234567890
Message #3
.'(:+"-!);-@?/&=_
Code: Select all
#include<iostream>
#include<string>
#include<sstream>
using namespace std;
char r(string q)
{
// this function will return what q is.
}
int main()
{
string q,t; int m; char c;
cin>>m; cin.get();
for(int i=1;i<=m;i++)
{
cout<<"Message #"<<i<<endl;
while(cin>>q)
{
cout<<r(q);
c=cin.get();
if(c=='\n')break;
if(cin.peek()==' '){cin.get();cout<<' ';}
}
cout<<endl;
if(i!=m)cout<<endl;
}
}
I see only one error in your output, that's in:PG wrote:I have tried all test case that everyone offered and passed all of them.
But I still got WA.
Code: Select all
Message #3
.'(:+"-!);#?/&=_
Code: Select all
#include <stdio.h>
#include <string.h>
struct IND
{
int r, c ;
} ;
char x[9][6][10] =
{
{ ".-", ".---", "...", ".----", ".-.-.-", "---..." },
{ "-...", "-.-", "-", "..---", "--..--", "-.-.-." },
{ "-.-.", ".-..", "..-", "...--", "..--..", "-...-" },
{ "-..", "--", "...-", "....-", ".----.", ".-.-." },
{ ".", "-.", ".--", ".....", "-.-.--", "-....-" },
{ "..-.", "---", "-..-", "-....", "-..-.", "..--.-" },
{ "--.", ".--.", "-.--", "--...", "-.--.", ".-..-." },
{ "....", "--.-", "--..", "---..", "-.--.-", ".--.-." },
{ "..", ".-.", "-----", "----.", ".-..." }
} ;
char L[9][10] =
{
"AJS1.:", "BKT2,;", "CLU3?=", "DMV4\'+", "ENW5!-", "FOX6/_", "GPY7(\"", "HQZ8)@", "IR09&"
} ;
IND SER( char p[] )
{
IND id ;
int r, c ;
for( r = 0; r < 9; r++ )
{
for( c = 0; c < 6; c++ )
{
if( !strcmp( x[r][c], p ) )
{
id.r = r ; id.c = c ; return id ;
}
}
}
}
int main ()
{
int T, i, l, kase ;
char s[3000], letter[10] ;
IND id ;
//freopen( "11223.in", "r", stdin ) ;
scanf( "%d", &T ) ;
kase = 1 ;
while( T-- )
{
scanf( " %[^\n]", s ) ;
printf( "Message #%d\n", kase++ ) ;
i = 0 ;
while( 1 )
{
sscanf( &s[i], "%[^ \0]", letter ) ;
l = strlen( letter ) ;
id = SER( letter ) ;
printf( "%c", L[id.r][id.c] ) ;
if( s[i+l] == '\0' ) break ;
if( s[i+l+1] == ' ' ) { printf( " " ) ; i++ ; }
i = i+l+1 ;
}
printf( "\n" ) ;
if( T ) printf( "\n" ) ;
}
return 0 ;
}
Code: Select all
#include<iostream>
#include<cstring>
#include<ctype.h>
using namespace std;
int main()
{
string st[]={".-","-...","-.-.","-..",".","..-.","--.","....","..",".---","-.-",".-..","--","-.","---",".--.","--.-",".-.","...","-","..-","...-",".--","-..-","-.--","--..","-----",".----","..---","...--","....-",".....","-....","--...","---..","----.",".-.-.-","--..--","..--..",".----.","-.-.--","-..-.","-.--.","-.--.-",".-...","---...","-.-.-.","-...-",".-.-.","-....-","..--.-",".-..-.",".--.-."};
string arr[]={"A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","0","1","2","3","4","5","6","7","8","9",".",",","?","'","!","/","(",")","&",":",";","=","+","-","_","\"","@"};
string m;
string a;
int t, in=1, i, j;
char ch;
bool f;
cin >> t;
cin.get();
while(t--)
{
cout << "Message #"<<in++<<endl;
a="";
getline(cin,m);
f=false;
for(i=0; i<=m.length(); i++)
{
if(m[i]==' '||i==m.length())
{
for(j=0; j<53; j++)
{
if(a==st[j])
{
cout << arr[j];
break;
}
}
a="";
if(m[i+1]==' ')
cout << " ";
}
else
{a+=m[i];}
}
cout << endl;
}
return 0;
}