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

几个坑……被坑了半个月QwQ

Posted by 23945 at 2016-06-22 22:26:00 on Problem 1259
  题解请参见
  这么做 (2855) zhangxiao1124 2008-05-02 17:54:15 Problem 1259
  十分感谢zhangxiao1124老师。%%%
  首先声明我是用的f[j][i]=f[k][j]+Area(j,i)的形式做的。(区别于f[k][j]->f[j][i],我是f[j][i] uses f[k][j])。
  然后我就遇到了样例……无情被卡极角排序相同之后的处理顺序。这里应该极角序同时先处理和当前原点距离远的。想想还是比较清晰的。
  然后我就遇到了这样一组数据:
1
14
1 6 9 11 6 12 10 4 1 3 12 3 11 7 0 0 4 9 12 10 5 2 2 7 2 6 16 9
  无情被卡上述一条直线去更新之后的点。因为我判断的时候会认定这条直线上的点不能去更新……
  然后我果断扩展判定方式,然后……
  样例过不了了……
  然后我发现这条直线只能做起始直线……于是我又加了一个判断,然后过了……
  悲伤辣么大QwQ
  
  如果实在需要代码,请向下滚动
























































































#include<cstdio>
#include<algorithm>
using namespace std;

const int NUM=105;

inline int max(int a,int b){ return a>b?a:b;}
inline int Abs(int a){ return a<0?-a:a;}

struct Point{
	int x,y;
}P[NUM],Q[NUM];
inline int Cross(Point a,Point b,Point o)
{	return (a.x-o.x)*(b.y-o.y)-(a.y-o.y)*(b.x-o.x);}
inline int SqDis(Point a,Point b)
{	return (a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y);}

int n;
void Read()
{	int i;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	 scanf("%d%d",&P[i].x,&P[i].y);
}

int m,f[NUM][NUM],OK[NUM][NUM];
inline bool AngCMP(Point a,Point b)
{	int tmp=Cross(a,b,Q[1]);
	if(tmp>0)return 1;
	if(tmp<0)return 0;
	return SqDis(Q[1],a)>SqDis(Q[1],b);
}
inline bool HoiCMP(Point a,Point b)
{	if(a.y==b.y)return a.x<b.x;
	return a.y<b.y;
}
void Load(int i)
{	m=0;
	for(int k=i;k<=n;k++)
	 Q[++m]=P[k];
	sort(Q+2,Q+1+m,AngCMP);
	/*
	printf("St::(%d, %d)\n",Q[1].x,Q[1].y);
	for(int k=1;k<=m;k++)
	 printf("  (%d, %d)",Q[k].x,Q[k].y);putchar('\n');
	*/
}
bool Tag;
bool Check(int L,int R)
{	Tag=0;
	for(int k=L+1;k<R;k++)
	{ if(Cross(Q[L],Q[k],Q[1])==0)Tag=1;
	  if(Cross(Q[L],Q[k],Q[1])!=0&&Cross(Q[R],Q[L],Q[k])<0)return 0;
	}
	return 1;
}
int Get()
{	int i,j,k,ret=0,tmp;
//	printf("!!! %d %d\n",Cross(Q[6],Q[3],Q[4]),Cross(Q[6],Q[3],Q[5]));
//	printf("!!! %d\n",Check(3,6));return 0;
	for(i=3;i<=m;i++)
	 for(j=2;j<i;j++)
	 { if(!Check(j,i))
	   { OK[j][i]=f[j][i]=0;continue;}
	   OK[j][i]=1;
	   f[j][i]=tmp=Abs(Cross(Q[1],Q[j],Q[i]));
	   if(Tag)goto END;
	   for(k=j-1;k>1;k--)
	    if(OK[k][j]&&Cross(Q[i],Q[k],Q[j])>=0)
	     f[j][i]=max(f[j][i],tmp+f[k][j]);
END:   ret=max(ret,f[j][i]);
	 }
//	 printf("i=%d\n",i);
//	 for(j=2;j<i;j++)printf(" %d",f[j][i]);putchar('\n');
//	}
	return ret;
}
void Solve()
{	int i,Ans=0;
	sort(P+1,P+1+n,HoiCMP);
	for(i=1;i<=n;i++)
//	for(i=1;i<=1;i++)
	{ Load(i);
	  Ans=max(Ans,Get());
//	  printf("   %.1f\n",(double)Ans/2.0);
	}
	printf("%.1f\n",(double)Ans/2.0);
}

int main(){
	int Kase;scanf("%d",&Kase);
	while(Kase--)
	{ Read();
	  Solve();
	}
	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