【结论+简单几何】HDU6147 Pokémon GO II
来源:互联网 发布:淘宝一键上传好不好 编辑:程序博客网 时间:2024/06/05 18:52
题面在这里
不难发现,第一次路径相交时,这两条线段出现的时间差不超过6
然后就很好搞了
注意判断线段相交有很多小细节
示例程序:
#include<cstdio>#include<cstring>#include<algorithm>#define LL long longusing namespace std;inline char nc(){ static char buf[100000],*p1=buf,*p2=buf; return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;}inline int red(){ int res=0,f=1;char ch=nc(); while (ch<'0'||'9'<ch) {if (ch=='-') f=-f;ch=nc();} while ('0'<=ch&&ch<='9') res=res*10+ch-48,ch=nc(); return res*f;}const int p[4][2]={{-1,0},{0,1},{1,0},{0,-1}};int tst,n;struct seg{ LL x,y,xx,yy; seg () {} seg (LL _x,LL _y,LL _xx,LL _yy):x(_x),y(_y),xx(_xx),yy(_yy) {} void maintain(){ if (x==xx){ if (y>yy) swap(y,yy); }else if (x>xx) swap(x,xx); } bool check(const seg&b){ if (x==xx&&y==yy) return 0; if (x==xx){ if (b.y==b.yy) return y<=b.y&&b.y<=yy && b.x<=x&&x<=b.xx; else return x==b.x&&!(b.yy<y||yy<b.y); }else{ if (b.x==b.xx) return x<=b.x&&b.x<=xx && b.y<=y&&y<=b.yy; else return y==b.y&&!(b.xx<x||xx<b.x); } }}a[10];int main(){ tst=red(); while (tst--){ n=red();memset(a,0,sizeof(a)); int til=0,i=0;LL x=0,y=0; bool suc=1; for (int j=1;j<=n;j++){ LL l=red(); a[til]=seg(x,y,x+p[i][0]*l,y+p[i][1]*l); a[til].maintain(); x+=p[i][0]*l;y+=p[i][1]*l;i=(i+1)%4; for (int k=0;k<6;k++) if (k!=til&&k!=(til+5)%6&&a[k].check(a[til])) {printf("%d\n",j);suc=0;break;} if (!suc) while (++j<=n) red(); til=(til+1)%6; } if (suc) printf("Catch you\n"); } return 0;}
阅读全文
2 0
- 【结论+简单几何】HDU6147 Pokémon GO II
- 【模拟】HDU6147[Pokémon GO II]题解
- HDU6147 Pokémon GO II (2017百度之星程序设计大赛
- hdu[6147] Pokémon GO II
- HUU6147 Pokémon GO II
- Pokémon GO
- [乱搞]Hdu 6147——Pokémon GO II
- Unbundling Pokémon Go
- HDU6146-Pokémon GO
- HDU6146 Pokémon GO
- hdu 6146 Pokémon GO(DP)
- HDU 6146:Pokémon GO
- HDU6146 Pokémon GO【DP】
- [递推] HDU6146 Pokémon GO
- Kubernetes 落地案例|将 Pokémon Go 运行到谷歌云上
- Kubernetes 落地案例|将 Pokémon Go 运行到谷歌云上
- HDU 6146 Pokémon GO (dp)
- 百度之星复赛--Pokémon GO----dp
- java 泛型
- .net MVC使用GetOrgChart实现树形关系结构组织架构图
- python基础
- Cisco Auditing Tool ----思科路由漏洞扫描
- myeclipse中的小红叉
- 【结论+简单几何】HDU6147 Pokémon GO II
- 框架搭建
- hdu6181 2017多校最短路(复习了一拨儿次短路)
- 腾讯大牛教你web前后端漏洞分析与防御-信息泄露
- mysql使用笔记
- How does maven work?
- 程序员的5年奋斗历程与规划
- python --- paramiko模块
- android开发之Toast