比赛 |
20140418 |
评测结果 |
AWWWWWWWWW |
题目名称 |
奶牛冰壶运动 |
最终得分 |
10 |
用户昵称 |
King |
运行时间 |
0.575 s |
代码语言 |
C++ |
内存使用 |
2.58 MiB |
提交时间 |
2014-04-18 08:44:43 |
显示代码纯文本
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
#define MAXN 100010
struct point
{
int x,y;
friend point operator -(point x,point y)
{
x.x-=y.x;x.y-=y.y;
return x;
}
friend int operator *(point x,point y)
{
return x.x*y.y-x.y*y.x;
}
}a[MAXN],b[MAXN],t[MAXN];
int n,ts,s;
bool cmp1(point x,point y)
{
return (x-a[1])*(y-a[1])>0;
}
bool cmp2(point x,point y)
{
return (x-b[1])*(y-b[1])>0;
}
bool check1(int d)
{
int sc=0;
for(int i=1;i<ts;i++)
{
int rec=(t[i]-b[d])*(t[i+1]-b[d]);
if(rec<0)rec=-rec;
sc+=rec;
}
return sc==s;
}
bool check2(int d)
{
int sc=0;
for(int i=1;i<ts;i++)
{
int rec=(t[i]-a[d])*(t[i+1]-a[d]);
if(rec<0)rec=-rec;
sc+=rec;
}
return sc==s;
}
void work1()
{
int mi=10000000,w;
for(int i=1;i<=n;i++)
if(a[i].x<mi){mi=a[i].x;w=i;}
swap(a[w],a[1]);
sort(a+2,a+1+n,cmp1);a[n+1]=a[1];
for(int i=1;i<=n+1;i++)
{
while(ts>1 && (a[i]-t[ts])*(t[ts]-t[ts-1])>=0){ts--;}
t[++ts]=a[i];
}
for(int i=1;i<ts;i++)s+=t[i]*t[i+1];
int ans=0;
for(int i=1;i<=n;i++)if(check1(i))ans++;
printf("%d ",ans);
}
void work2()
{
int mi=10000000,w;
ts=0;
for(int i=1;i<=n;i++)
if(b[i].x<mi){mi=b[i].x;w=i;}
swap(b[w],b[1]);
sort(b+2,b+1+n,cmp2);b[n+1]=b[1];
for(int i=1;i<=n+1;i++)
{
while(ts>1 && (b[i]-t[ts])*(t[ts]-t[ts-1])>=0){ts--;}
t[++ts]=b[i];
}
s=0;
for(int i=1;i<ts;i++)s+=t[i]*t[i+1];
int ans=0;
for(int i=1;i<=n;i++)if(check2(i))ans++;
printf("%d\n",ans);
}
int main()
{
freopen("curling.in","r",stdin);
freopen("curling.out","w",stdout);
scanf("%d",&n);
for(int i=1;i<=n;i++)scanf("%d%d",&a[i].x,&a[i].y);
for(int i=1;i<=n;i++)scanf("%d%d",&b[i].x,&b[i].y);
work1();work2();
return 0;
}