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 »

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 »

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 »

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''
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 »

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 »

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 »

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 »

got ac
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 »

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 »

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 »

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 »

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 »

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 »

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 »

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 »

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

Return to “Volume 102 (10200-10299)”