显示代码纯文本
#include<bits/stdc++.h>
#define MAXN 310
using namespace std;
struct Point{
int x,y;
}p[MAXN];
struct Vec{
int x,y;
};
int Cross(Vec a,Vec b){return a.x*b.y-b.x*a.y;}
bool Under(Point a,Point b){//b是否在a下方
return b.x==a.x&&b.y<a.y;
}
bool cmp(Point a,Point b){return a.x<b.x;}
bool Judge(Point a,Point b,Point c){//检查c是否在a,b构成的线段下方
if(a.x>b.x)swap(a,b);
if(c.x<a.x||c.x>b.x)return 0;
Vec x=(Vec){b.x-a.x,b.y-a.y};
Vec y=(Vec){c.x-a.x,c.y-a.y};
int temp=Cross(y,x);
return temp>0;
}
int N,ans1,ans2,temp,num[MAXN][MAXN];
int main(){
freopen("trib.in","r",stdin);
freopen("trib.out","w",stdout);
scanf("%d",&N);
for(int i=1;i<=N;i++)scanf("%d%d",&p[i].x,&p[i].y);
sort(p+1,p+1+N,cmp);
for(int i=1;i<=N;i++){
for(int j=1;j<=N;j++){if(i!=j)if(Under(p[i],p[j]))num[i][i]++;}
for(int j=i+1;j<=N;j++){
for(int k=1;k<=N;k++){
if(k!=i&&k!=j)if(Judge(p[i],p[j],p[k]))num[i][j]++,num[j][i]++;
}
}
}
for(int i=1;i<=N;i++){
for(int j=i+1;j<=N;j++){
for(int k=j+1;k<=N;k++){
int temp;
if(Judge(p[i],p[k],p[j]))temp=num[i][k]-num[i][j]-num[j][k]+num[j][j]+2;
else temp=num[i][j]+num[j][k]-num[j][j]-num[i][k]+3;
if(temp>ans1)ans1=temp,ans2=1;
else if(temp==ans1)ans2++;
}
}
}
printf("%d\n%d",ans1,ans2);
return 0;
}