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

mf
Guru
Posts: 1244
Joined: Mon Feb 28, 2005 4:51 am
Location: Zürich, Switzerland
Contact:

Post by mf » Fri Sep 14, 2007 5:51 pm

Compiler was updated recently. If you want to avoid compilation errors, it's best to download and use gcc.
So why it conflicts with previous declaration `char* index(const char*, int)' . Its really hard to understand.
There's a system function called index, and in C/C++ you can't use the same identifier to name two different things (a function and a variable) in the same scope (global, in this case).

ishtiaq ahmed
Learning poster
Posts: 53
Joined: Sat Jul 29, 2006 7:33 am
Location: (CSE,DU), Dhaka,Bangladesh

post reply

Post by ishtiaq ahmed » Fri Sep 14, 2007 6:03 pm

Dear mf,
Thank you very much. But its WA now. What can i do?
Here is my code

Code: Select all

the code is removed
thanks.
No venture no gain

with best regards
------------------------
ishtiaq ahmed

turcse143
Learning poster
Posts: 81
Joined: Wed May 09, 2007 9:59 pm
Location: (CSE,DU) Dhaka,Bangladesh

Post by turcse143 » Sat Feb 09, 2008 9:10 am

thanks a lot.
i use qsort then binary seach & get accepted.
for the TLE i use binary search.
''I want to be most laziest person in the world''

User avatar
newton
Experienced poster
Posts: 162
Joined: Thu Jul 13, 2006 7:07 am
Location: Campus Area. Dhaka.Bangladesh
Contact:

Re: 10282 - Babelfish

Post by 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.

helloneo
Guru
Posts: 516
Joined: Mon Jul 04, 2005 6:30 am
Location: Seoul, Korea

Re: 10282 - Babelfish

Post by 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

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

Re: 10282 - Babelfish

Post by jahin » Wed Oct 22, 2008 12:46 pm

im getting RTE .

but why??
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

Post by jahin » Wed Oct 22, 2008 7:53 pm

got ac

User avatar
newton
Experienced poster
Posts: 162
Joined: Thu Jul 13, 2006 7:07 am
Location: Campus Area. Dhaka.Bangladesh
Contact:

Re: 10282 - Babelfish

Post by newton » Thu Oct 23, 2008 8:40 pm

jahin wrote:
got ac
if it is

remove ur AC code please

tajbir2000
New poster
Posts: 19
Joined: Fri Sep 05, 2008 6:39 pm
Location: bangladesh
Contact:

Re: 10282 - Babelfish

Post by 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;
}

zobayer
Experienced poster
Posts: 110
Joined: Tue May 06, 2008 2:18 pm
Location: CSE-DU, Bangladesh
Contact:

Re: 10282 - Babelfish

Post by 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.

sith
Learning poster
Posts: 72
Joined: Sat May 19, 2012 7:46 pm

Re: 10282 - Babelfish

Post by 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.

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 10282 - Babelfish

Post by brianfry713 » Wed Jun 27, 2012 11:59 pm

Use a map, not a hashCode.
Check input and AC output for thousands of problems on uDebug!

sith
Learning poster
Posts: 72
Joined: Sat May 19, 2012 7:46 pm

Re: 10282 - Babelfish

Post by sith » Thu Jun 28, 2012 10:10 am

Thank you. It works

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

Re: 10282 - Babelfish

Post by 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.

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 10282 - Babelfish

Post by brianfry713 » Mon Feb 11, 2013 12:49 am

Try using a map.
Check input and AC output for thousands of problems on uDebug!

Post Reply

Return to “Volume 102 (10200-10299)”