# BZOJ 4206: 最大团

## 4206: 最大团

Time Limit: 10 Sec  Memory Limit: 256 MB
Submit: 91  Solved: 36
[Submit][Status][Discuss]

6 3
0 6
-7 -4
-3 -2
7 -5
-2 3
8 -3

4

## 分析：

$l_1<l_2<l_3<......<l_n<r_1<r_2<r_3<......<r_n$

## 代码：

#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
//by NeighThorn
using namespace std;

const int maxn=2000+5;
const double pi=acos(-1.0),inf=1e8;

int n,ans,cas;
double r,tmp[maxn],posx[maxn],posy[maxn];

struct M{

double x,y;
int del;

inline void init(void){
del=0;
}

friend bool operator < (M a,M b){
if(a.del!=b.del) return a.del<b.del;
if(a.x!=b.x) return a.x<b.x;
if(a.y!=b.y) return a.y<b.y;
}

}no[maxn];

signed main(void){
scanf("%d%lf",&n,&r);
for(int i=1;i<=n;i++)
scanf("%lf%lf",&posx[i],&posy[i]),no[i].init();
for(int i=1,x,y;i<=n;i++){
double len=sqrt(posx[i]*posx[i]+posy[i]*posy[i]);
if(len<=r){
no[i].del=1;break;
}
double ang1=atan2(posy[i],posx[i]),ang2=acos(r/len);
no[i].x=ang1-ang2;no[i].y=ang1+ang2;
if(no[i].y>pi) no[i].y-=2*pi,swap(no[i].x,no[i].y);
if(no[i].x<-pi) no[i].x+=2*pi,swap(no[i].x,no[i].y);
}
sort(no+1,no+n+1);ans=0;
while(no[n].del==1) n--;
for(int i=1;i<=n;i++){
double x=no[i].x,y=no[i].y;
for(int j=0;j<n;j++) tmp[j]=inf;
for(int j=i+1;j<=n&&no[j].x<y;j++){
if(no[j].y>no[i].y)
*lower_bound(tmp,tmp+n,no[j].y)=no[j].y;
}
ans=max(ans,(int)(lower_bound(tmp,tmp+n,inf)-tmp)+1);
}
printf("%d\n",ans);
return 0;
}


By NeighThorn

posted @ 2017-04-11 17:03  NeighThorn  阅读(321)  评论(0编辑  收藏  举报