Page 4 of 8

Posted: Sat Dec 10, 2005 3:51 pm
by Martin Macko
jjtse wrote:does anyone know what was wrong with watershed's code?
I don't know. He hasn't replied any more.

Posted: Sat Dec 10, 2005 4:53 pm
by Martin Macko
smilitude wrote:code edited....
now what's wrong?

here it checks every single new word, whether they are really new or not
Are you sure it gives RE? It looks like it should give WA. You write an empty string to the output if the input begins with a non-alpha character.

Posted: Sat Dec 10, 2005 11:26 pm
by jjtse
Thanks, you are correct from the other topic. I fixed it and got AC. Thanks

Posted: Sat Dec 10, 2005 11:26 pm
by jjtse
Thanks. I got AC.

Posted: Sat Dec 10, 2005 11:31 pm
by Martin Macko
jjtse wrote:Thanks. I got AC.
After you got accepted, please, remove the code to make the topic more readable and not to create unnecessary spoilers.

Posted: Sun Dec 11, 2005 1:09 pm
by Martin Macko
roticv wrote:I did according to what was mentioned above, but I still keep getting WA.
code wrote:................pch = strtok(str," :\\;,./\n\t\'"`~!@#$%^&*-_+=1234567890");
Are you sure these are all delimiters that are in the input?

Posted: Fri Jan 13, 2006 7:44 am
by smilitude
Martin Macko wrote:
smilitude wrote:code edited....
now what's wrong?

here it checks every single new word, whether they are really new or not
Are you sure it gives RE? It looks like it should give WA. You write an empty string to the output if the input begins with a non-alpha character.
i think i wrote this ---

Code: Select all

if(words[i][0]!=' ') 
            printf("%s\n",words[i]);
are you sure martin macko?

Posted: Fri Jan 13, 2006 7:48 am
by smilitude
sorry, it gives output limit exceeded now.
what shd i do?

Posted: Fri Jan 13, 2006 10:42 pm
by Mohammad Mahmudur Rahman
That means your program somehow manages to get into an infinite loop which I think not very unlikely in this input format. :roll:
You can try my peculiar input strategy for this one.

Code: Select all

scanf(" %[^ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz]",buf);
while(scanf(" %[ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz]",buf)==1)
{
    //process
    scanf(" %[^ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz]",buf);

}

Posted: Fri Jan 20, 2006 8:42 am
by smilitude
i was so annoyed with this prob so i finally solved this using hashing.
thanks mahmud bhai and sunny!

10815 RTE help me!!

Posted: Mon Feb 06, 2006 6:45 am
by qazxcvbn

Code: Select all

#include<iostream>
#include<string.h>
#include<ctype.h>
#include<stdio.h>

using namespace std;

struct tree
{
	tree();
	tree* left;
	tree* right;
	char* content;
};
tree::tree()
{
	left=NULL;
	right=NULL;
	content=NULL;
}
void build(tree* bitree,char *str,int *count);
void post(tree *bitree);
int main()
{
	char str[200];
	char *temp=NULL;
	tree root;
	int i;
	int countword=0;
	while(countword<5000&&scanf("%s",str)==1)
	{
		for(i=0;str[i];i++)
		{
			if('A'<=str[i]&&str[i]<='Z')
			{
				str[i]=tolower(str[i]);
			}
			else if(!('a'<=str[i]&&str[i]<='z'))
			{
				str[i]=' ';
			}
		}
		temp=strtok(str," ");
		while(temp!=NULL)
		{
			build(&root,temp,&countword);
			temp=strtok(NULL," ");			
		}
		temp=NULL;
	}
	post(&root);
	return 0;
}
void build(tree* bitree,char *str,int *count)
{
	if(bitree->content==NULL)
	{
		bitree->content=new char [strlen(str)];
		(*count)++;
		strcpy(bitree->content,str);
	}
	else if(strcmp(bitree->content,str)<0)
	{
		if(bitree->left==NULL)
		{
			bitree->left=new tree;
		}
		build(bitree->left,str,count);
	}
	else if(strcmp(bitree->content,str)>0)
	{
		if(bitree->right==NULL)
		{
			bitree->right=new tree;
		}
		build(bitree->right,str,count);
	}
	return;
}
void post(tree *bitree)
{
	if(bitree->right!=NULL)
	{
		post(bitree->right);
	}
	cout<<bitree->content<<endl;
	if(bitree->left!=NULL)
	{
		post(bitree->left);
	}
	return;
}

I don't know what ERROR in it.Please help me.Thanks.

10815 WHY CE???????!!!!! CRAZY!!!!!!!1

Posted: Thu Aug 17, 2006 10:40 am
by Staryin

Code: Select all

#include <iostream>
#include <string>
#include <map>
#include <ctype.h>
#include <cstdlib>

using namespace std;

map<string,int> dict;
map<string,int>::iterator itr;


int main()
{
   string in;
   while(cin>>in)
   {
      string temp;
      temp.clear();
      
      for(int i = 0; i < in.size();i++)
         {

            temp +=(char)tolower(in[i]);
            if(!isalpha(temp[i]))temp[i] = ' ';
         }
      in.clear();
      for(int i = 0; i < temp.size();i++)
         if(isalpha(temp[i]))in+=(char)temp[i];

      dict[in] = 1;
   }
   for(itr = dict.begin();itr!=dict.end();itr++)
     cout<<itr->first<<endl;

   return 0;
}

Re: 10815 WHY CE???????!!!!! CRAZY!!!!!!!1

Posted: Thu Aug 17, 2006 3:08 pm
by Martin Macko
I've just replied you in the other thread you created. (btw, please, never create two or more threads on the same problem.)

Posted: Wed Nov 22, 2006 9:13 pm
by kolpobilashi
checked all previous posts and the code seems ok, but it gives WA. would anyone kindly hav a look... :(

Code: Select all

cut..
btw, i never used set, thats why i use map here...but it seems ok :roll:
thanx in advance.

Posted: Wed Nov 22, 2006 9:58 pm
by asif_rahman0
You missed the problem statement!!!

Code: Select all

sorted in alphabetical order
So add the following line to sort in map<const char *s,int,cmm>

Code: Select all

struct cmm{
	bool operator()(const char *str1,const char *str2) const
	{
		return strcmp(str1,str2)<0;	
	}
};
btw, how did you check all posts? Even have you checked Sample I/O!!!