Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

only one single case in each input file

Posted by frkstyc at 2005-05-27 21:46:31
In Reply To:Re:i didn't, bst is enough efficient Posted by:SuperDog at 2005-05-27 21:39:56
> 不是TLE啊,是RUNTIME ERROR,我用小数据测试过是没问题的,数组也足够大,真是好奇怪.
> 
> 贴个code,高手帮忙看一下
> #include <stdio.h>
> #include <string>
> struct node
> {
> 	char name[100];
> 	long num;
> 	long left,right;
> };
> node specie[11000];
> char c;
> long total,i,j;
> bool flag;
> char temp[100];
> void putintotree(char spname[], int position)
> {
> 	int x;
> 	if (strcmp(specie[position].name,"")==0) 
>          {strcpy(specieposition].name,spname); specie[position].num++; }
> 	else
> 	{
> 		x=strcmp(spname,specie[position].name);
> 		if (x==0) specie[position].num++;
> 		if (x<0)
> 		{
> 		if (specie[position].left==0) 
>                     specie[position].left=total;
> 		putintotree(spname,specie[position].left);
> 		}
> 		if (x>0)
> 		{
> 		if (specie[position].right==0) 
>                     specie[position].right=total;
> 		putintotree(spname,specie[position].right);
> 		}
> 	}
> }
> 
> void printtree(int position)
> {
> 	if (specie[position].left!=0) printtree(specie[position].left);
> 	printf("%s %.4lf\n",
>         specie[position].name,double(specie[position].num)*100/total);
> 	if (specie[position].right!=0) 
>          printtree(specie[position].right);
> }
> int main()
> {  
>    //freopen("input.txt","r",stdin);
> 	memset(specie,0,sizeof(specie));
> 	total=0;  flag=false;
> 	while (gets(temp) && strcmp(temp,"")!=0)
> 	{
> 		total++; 
> 		if (flag==true) printf("\n"); 
> 		else flag=true;
> 		putintotree(temp,1); 
> 		while (gets(temp))
> 		{
> 			if (strcmp(temp,"")!=0) 
> 			{
> 				total++; 
> 				putintotree(temp,1); 
> 			}
>             else break;
> 		}
> 		if (total!=0) printtree(1);
> 		total=0;
>     	memset(specie,0,sizeof(specie));
> 	}
> 	return 0;
> }

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator