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

这样会超时

Posted by frkstyc at 2005-05-18 21:40:08 on Problem 2104
In Reply To:这题有什么边缘数据吗?测试数据通过了,怎么还不对?能帮我看一下吗?谢谢. Posted by:bird at 2005-05-18 21:30:36
> #include <cstdio>
> inline long *partion(long *s,long *e)
> {
> 	long *p=s;
> 	for(long *x=s+1;x<e;x++)
> 		if(*x<=*s&&++p!=x)
> 		{
> 			long temp=*x;
> 			*x=*p;
> 			*p=temp;
> 		}
> 	long temp=*s;
> 	*s=*p;
> 	*p=temp;
> 	return p;
> }
> long f(long *s,long *e,long *key)
> {
> 
> 	long *x=e-1;
> 	while(x!=key)
> 	{
> 		if(x>key)x=partion(s,x);
> 		else x=partion(x+1,e);
> 	}
> 	return *x;
> }
> int main()
> {
> 	long n,m;
> 	scanf("%d%d",&n,&m);
> 	long *a=new long[n],*p=a;
> 	while(n--)scanf("%d",p++);
> 	while(m--)
> 	{
> 		int i,j,k;
> 		scanf("%d%d%d",&i,&j,&k);
> 		int N=j-i+1;
> 		long *b=new long[N],*q=b;
> 		p=a+i-1;
> 		while(N--)*(q++)=*(p++);
> 		printf("%d\n",f(b,q,b+k-1));
> 		delete []b;
> 	}
> 	delete []a;
> 	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