10282 - Babelfish

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

Moderator: Board moderators

Re: 10282 - Babelfish

Postby newton » Fri Jul 04, 2008 12:54 am

Thank You.
It was really a chilly mistake.
Code: Select all
Accepted

keep posting.
Last edited by newton on Fri Jul 04, 2008 12:25 pm, edited 1 time in total.
User avatar
newton
Experienced poster
 
Posts: 162
Joined: Thu Jul 13, 2006 7:07 am
Location: Campus Area. Dhaka.Bangladesh

Re: 10282 - Babelfish

Postby helloneo » Fri Jul 04, 2008 5:23 am

newton wrote:why Compilation Error?
And also say is my algorithm correct? will the code be accepted after correction?



Try this..

Code: Select all
int comp(const void *a,const void *b) {


and..

Code: Select all
int binSearch(char *p,int n){



Binary search is a correct algorithm to solve this problem..
Remove your code after AC
helloneo
Guru
 
Posts: 516
Joined: Mon Jul 04, 2005 6:30 am
Location: Seoul, Korea

Re: 10282 - Babelfish

Postby jahin » Wed Oct 22, 2008 12:46 pm

im getting RTE .

but why??

Code: Select all
Last edited by jahin on Fri Oct 24, 2008 4:40 am, edited 1 time in total.
jahin
New poster
 
Posts: 3
Joined: Wed Apr 02, 2008 8:52 pm

Re: 10282 - Babelfish

Postby jahin » Wed Oct 22, 2008 7:53 pm

got ac
jahin
New poster
 
Posts: 3
Joined: Wed Apr 02, 2008 8:52 pm

Re: 10282 - Babelfish

Postby newton » Thu Oct 23, 2008 8:40 pm

jahin wrote:
got ac


if it is

remove ur AC code please
User avatar
newton
Experienced poster
 
Posts: 162
Joined: Thu Jul 13, 2006 7:07 am
Location: Campus Area. Dhaka.Bangladesh

Re: 10282 - Babelfish

Postby tajbir2000 » Wed Sep 02, 2009 6:52 pm

I am getting WA.....Where is the problem?
Code: Select all
#include<iostream>
#include<map>
#include<string>

using namespace std;
map<string,int>M;
typedef struct{
   char final[205];
}data;
data A[100005];

int main(){
   int i,cnt,j,k;
   char str[205],tempa[200],tempb[200];
   
   //freopen("i.txt","r",stdin);
   cnt=0;
   
   while(gets(str)){
      if(!strcmp(str,""))
         break;
      i=0;
      while(1){
         if(str[i]==' ')
            break;
         i++;
      }
      
      for(j=0;j<i;j++)
         tempa[j]=str[j];
      tempa[j]='\0';
      strcpy(A[cnt].final,tempa);
      
      for(k=0,j=i+1;str[j];j++,k++)
         tempb[k]=str[j];
      tempb[k]='\0';
      
      M[tempb]=cnt;
      cnt++;
      memset(tempa,NULL,sizeof(tempa));
      memset(tempb,NULL,sizeof(tempb));
      memset(str,NULL,sizeof(str));
   }
   while(gets(str)){
      if(M[str]){
         printf("%s\n",A[M[str]].final);
      }
      else
         printf("eh\n");
   }
   return 0;
}
tajbir2000
New poster
 
Posts: 19
Joined: Fri Sep 05, 2008 6:39 pm
Location: bangladesh

Re: 10282 - Babelfish

Postby zobayer » Fri Nov 26, 2010 10:36 am

so? everyone forgot about the TRIE :D ????
You should not always say what you know, but you should always know what you say.
zobayer
Experienced poster
 
Posts: 110
Joined: Tue May 06, 2008 2:18 pm
Location: CSE-DU, Bangladesh

Re: 10282 - Babelfish

Postby sith » Wed Jun 27, 2012 9:25 pm

Hello

I've got WA, Why? Is it because of my simple implementation of map?

Code: Select all
AC
Last edited by sith on Thu Jun 28, 2012 10:11 am, edited 1 time in total.
sith
Learning poster
 
Posts: 67
Joined: Sat May 19, 2012 7:46 pm

Re: 10282 - Babelfish

Postby brianfry713 » Wed Jun 27, 2012 11:59 pm

Use a map, not a hashCode.
brianfry713
Guru
 
Posts: 1755
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 10282 - Babelfish

Postby sith » Thu Jun 28, 2012 10:10 am

Thank you. It works
sith
Learning poster
 
Posts: 67
Joined: Sat May 19, 2012 7:46 pm

Re: 10282 - Babelfish

Postby kier.guevara » Sun Feb 10, 2013 9:23 pm

Code: Select all
ACCEPTED


Why did I get a TLE? I used the sort function and do a binary search. Is the sort and binary search not efficient enough for this problem?
Last edited by kier.guevara on Mon Feb 11, 2013 2:33 am, edited 1 time in total.
kier.guevara
New poster
 
Posts: 29
Joined: Thu Jul 19, 2012 11:24 pm

Re: 10282 - Babelfish

Postby brianfry713 » Mon Feb 11, 2013 12:49 am

Try using a map.
brianfry713
Guru
 
Posts: 1755
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 10282 - Babelfish

Postby kier.guevara » Mon Feb 11, 2013 2:32 am

Thanks brianfy for the tip! got AC!
kier.guevara
New poster
 
Posts: 29
Joined: Thu Jul 19, 2012 11:24 pm

Previous

Return to Volume CII

Who is online

Users browsing this forum: Bing [Bot] and 1 guest