10282 - Babelfish
Moderator: Board moderators
-
- New poster
- Posts: 30
- Joined: Thu Jul 19, 2012 11:24 pm
Re: 10282 - Babelfish
Thanks brianfy for the tip! got AC!
10282 - Babelfish
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;
}
//---------------------------------------
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;
}
//---------------------------------------
-
- Guru
- Posts: 5947
- Joined: Thu Sep 01, 2011 9:09 am
- Location: San Jose, CA, USA
Re: 10282 - Babelfish
Click My Submissions to see the reason for your CE.
Check input and AC output for thousands of problems on uDebug!
Re: 10282 - Babelfish
Here's some input / output that I found useful during testing / debugging.
Input:
AC Output:
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
Code: Select all
cat
eh
loops
kitten
eh
eh
paper