显示代码纯文本
#include<cstdio>
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
const int SIZEN=310;
const double zero=1e-7;
class miku
{
public:
int x,y;
}P[SIZEN];
int N,ans=0;
void read()
{
scanf("%d",&N);
for(int i=1;i<=N;i++)
scanf("%d%d",&P[i].x,&P[i].y);
}
int det(miku a,miku b,miku c)
{
return (b.x-a.x)*(c.y-a.y)-(c.x-a.x)*(b.y-a.y);
}
bool under(miku a,miku b,miku c)
{
if(c.x>a.x&&c.x<=b.x&&det(a,b,c)<=0) return 1;
return 0;
}
int sumunder(miku a,miku b)
{
int ans=0;
for(int i=1;i<=N;i++)
{
if(under(a,b,P[i])) ans++;
}
return ans;
}
int sum[SIZEN][SIZEN]={0};
bool cmp(miku a,miku b)
{
if(a.x==b.x) return a.y<b.y;
return a.x<b.x;
}
void work()
{
int ans=0,cnt=0;
sort(P+1,P+1+N,cmp);
for(int i=1;i<=N;i++) for(int j=i+1;j<=N;j++) sum[i][j]=sumunder(P[i],P[j]);
for(int i=1;i<=N;i++)
for(int j=i+1;j<=N;j++)
{
for(int k=j+1;k<=N;k++)
{
int left=i,mid=j,right=k;
int tem=0;
if(P[left].x==P[mid].x)
{
tem=sum[mid][right]-sum[left][right]+3;
}
else if(P[right].x==P[mid].x)
{
tem=sum[left][right]-sum[left][mid]+2;
}
else if(under(P[i],P[k],P[j]))
{
tem=sum[left][right]-sum[left][mid]-sum[mid][right]+3;
}
else
{
tem=sum[left][mid]+sum[mid][right]-sum[left][right]+2;
}
if(tem>ans)
{
ans=tem;
cnt=1;
}
else if(tem==ans)
{
cnt++;
}
}
}
printf("%d %d",ans,cnt);
}
int main()
{
freopen("trib.in","r",stdin);
freopen("trib.out","w",stdout);
read();
work();
return 0;
}