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

可爱的堆啊~~~终于不TLE了

Posted by checkoj at 2010-02-22 15:25:01 on Problem 2312 and last updated at 2010-02-22 15:26:36
堆,明白吗?
就是int X[90001],Y[90001],R[90001],N;
void Min(int i)//keep R[1] min
{
	int L=(i<<1),m=i;
	if(L<=N&&R[L]<R[m])m=L;
	L++;
	if(L<=N&&R[L]<R[m])m=L;
	if(m!=i)
	{
		L=R[i];R[i]=R[m];R[m]=L;
		L=X[i];X[i]=X[m];X[m]=L;
		L=Y[i];Y[i]=Y[m];Y[m]=L;
		Min(m);
	}
}
void Up(int i)//Add num
{
	if(i==1)return;
	int F=(i>>1);
	if(R[F]>R[i])
	{
		int T=R[i];R[i]=R[F];R[F]=T;
		T=X[i];X[i]=X[F];X[F]=T;
		T=Y[i];Y[i]=Y[F];Y[F]=T;
		Up(F);
	}
}

//PS:   Accepted        932K	16MS	C++	1612B

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