Codeforces Gym 101234H Split Game
来源:互联网 发布:快手视频制作软件 编辑:程序博客网 时间:2024/05/17 23:03
按极角扫描,显然只有经过端点的时候数量才会改变。大力讨论一下,注意区分“转到这个点就改变”和“转过这个点才改变”两种情况。
#include<cstdio>#include<cmath>#include<algorithm>using namespace std;#define LL long longconst int maxn=200010,eps=1e-8;struct Vector{ LL x,y; void rd() { scanf("%I64d%I64d",&x,&y); } Vector operator + (const Vector &v) const { return (Vector){x+v.x,y+v.y}; } Vector operator - (const Vector &v) const { return (Vector){x-v.x,y-v.y}; }}a[maxn];LL cross(Vector v,Vector u){ return v.x*u.y-v.y*u.x;}int f[maxn],del[maxn],n,ans,now;int comp(int x,int y){ return cross(a[x],a[y])>0;}int main(){ //freopen("a.in","r",stdin); int tem,nn=0; scanf("%d",&n); for (int i=1;i<=n;i++) a[i].rd(); a[0]=a[n]; a[n+1]=a[1]; for (int i=1;i<=n;i++) if (!cross(a[i]-a[i-1],a[i+1]-a[i-1])) del[i]=1; for (int i=1;i<=n;i++) if (!del[i]) a[++nn]=a[i]; n=nn; a[0]=a[n]; a[n+1]=a[1]; for (int i=1;i<=n;i++) f[i]=i; sort(f+1,f+n+1,comp); for (int i=1,j;i<=n;i=j) { tem=0; for (j=i;j<=n&&!cross(a[f[i]],a[f[j]]);j++) { if (cross(a[f[j]],a[f[j]-1])>=0&&cross(a[f[j]],a[f[j]+1])>0) { if (cross(a[f[j]-1]-a[f[j]],a[f[j]+1]-a[f[j]])>0) now++; else tem++; } if (cross(a[f[j]],a[f[j]-1])<0&&cross(a[f[j]],a[f[j]+1])<=0) { if (cross(a[f[j]-1]-a[f[j]],a[f[j]+1]-a[f[j]])<0) now--; else tem--; } } ans=max(ans,now); now+=tem; ans=max(ans,now); } printf("%d\n",ans+1);}
阅读全文
0 0
- Codeforces Gym 101234H Split Game
- Codeforces Gym 101234D Forest Game
- Codeforces Gym 101234E Lines Game
- codeforces GYM 100792H
- 【Codeforces Gym】100162 H Temperature
- Codeforces Gym 100623H Problem H. Holes
- Codeforces Gym 100814J Game 简单博弈
- Codeforces Gym 100342H Hard Test 构造
- CodeForces Gym 100989H Queue (A)
- Codeforces Gym 100962 H. Hans Zimmer
- [DP] Codeforces Gym 101002 H. Jewel Thief
- GYM 100090 H.Game with the Stones(博弈论)
- [Codeforces Gym] 100162A Box Game 博弈+二分图匹配
- Codeforces Gym 100650C The Game of Efil DFS
- [博弈论] Codeforces Gym 101190 NEERC 16 G. Game on Graph
- Codeforces Gym 100345H Settling the Universe Up Bitset+倒推
- [Codeforces Gym]100162 H - Temperature 状态压缩dp
- codeforces Gym 100500Problem H. ICPC Quest 简单DP
- 理解strcat、strncat、strcpy、strncy、strcmp、strncmp。
- es6-变量解构赋值
- VB-TabIndex、GotFocus、SetFocus
- Linux学习笔记 --Bash ScriptsII
- 网站10000IP要多少带宽才合适
- Codeforces Gym 101234H Split Game
- MySQL日常练习;
- 进制的基础与进阶
- 10.while循环
- 在 Ubuntu 16.04 中 安装为知笔记
- 变量占据的字节数的问题。
- Java开发工具的安装
- 11.循环控制
- Java Object类型能不能强制转化为值类型