10282 - Babelfish

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

Moderator: Board moderators

kier.guevara
New poster
Posts: 30
Joined: Thu Jul 19, 2012 11:24 pm

Re: 10282 - Babelfish

Post by kier.guevara »

Thanks brianfy for the tip! got AC!
eop
New poster
Posts: 1
Joined: Wed Oct 24, 2012 2:59 pm

10282 - Babelfish

Post by eop »

i have gotten AC with my STL::map version

but this one, my Hash version submission got a CE

i see no problem compiling on my own computer with Dev-C++ 4.9.9.2

can somebody please help me!!!!!

my code:
//by eop
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
#define Hash 3
char index[100005][15];
int dic[60000],top=1;
char s[50];
int main ()
{
while ( gets(s)!=NULL && strlen(s) ) {
char a[15],b[15]; sscanf(s,"%s %s",a,b);
strcpy(index[top],a);
int tmp=0,n=strlen(b);
for ( int i=0; i<n; i++ ) tmp=tmp*3+b-'a';
dic[tmp]=top++;
}
while ( gets(s)!=NULL ) {
int tmp=0,n=strlen(s);
for ( int i=0; i<n; i++ ) tmp=tmp*3+s-'a';
if ( !dic[tmp] ) puts("eh");
else puts(index[dic[tmp]]);
}
return 0;
}
//---------------------------------------
brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 10282 - Babelfish

Post by brianfry713 »

Click My Submissions to see the reason for your CE.
Check input and AC output for thousands of problems on uDebug!
uDebug
A great helper
Posts: 475
Joined: Tue Jul 24, 2012 4:23 pm

Re: 10282 - Babelfish

Post by uDebug »

Here's some input / output that I found useful during testing / debugging.

Input:

Code: Select all

dog ogday
cat atcay
pig igpay
froot ootfray
loops oopslay
kitten booskay
paper koopsmay

atcay
ittenkay
oopslay
booskay
kitten
booskays
koopsmay
AC Output:

Code: Select all

cat
eh
loops
kitten
eh
eh
paper
Check input and AC output for over 7,500 problems on uDebug!

Find us on Facebook. Follow us on Twitter.
Post Reply

Return to “Volume 102 (10200-10299)”