E. The Supersonic Rocket Codeforces Round #502 (in memory of Leopoldo Taravilse, Div. 1 + Div. 2)
http://codeforces.com/contest/1017/problem/E
凸包模板+kmp
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <time.h>
#include <string>
#include <set>
#include <map>
#include <list>
#include <stack>
#include <queue>
#include <vector>
#include <bitset>
#include <ext/rope>
#include <algorithm>
#include <iostream>
using namespace std;
#define ll long long
#define minv 1e-10
#define inf 1e9
#define pi 3.1415926536
#define E 2.7182818284
const ll mod=1e9+;//
const int maxn=1e5+; struct node
{
ll x,y;
}a[maxn],b[maxn],e[maxn],f[maxn],point; int p[maxn*];
double c[maxn*],d[maxn*]; ///result only 1/0
int cmp(node a,node b)
{
ll s=(a.y-point.y)*(b.x-point.x) - (b.y-point.y)*(a.x-point.x);
if (s<)
return ;
else if (s>)
return ;
else
return pow(a.y-point.y,)+pow(a.x-point.x,) < pow(b.y-point.y,)+pow(b.x-point.x,);
} void work(node a[],double c[],node e[],int n,int* z)
{
int i,g;
for (i=;i<=n;i++)
{
scanf("%lld%lld",&a[i].x,&a[i].y);
if (a[].x>a[i].x || (a[].x==a[i].x && a[].y>a[i].y))
swap(a[i],a[]);
}
point=a[];
sort(a+,a+n+,cmp); e[].x=a[].x,e[].y=a[].y;
e[].x=a[].x,e[].y=a[].y;
g=;
for (i=;i<=n;i++)
{
while (g> && (a[i].x-e[g-].x)*(e[g].y-e[g-].y)-(e[g].x-e[g-].x)*(a[i].y-e[g-].y)>=)
g--;
g++;
e[g].x=a[i].x,e[g].y=a[i].y;
}
e[g+]=e[];
e[]=e[g]; for (i=;i<=g;i++)
{
//len^2 cos(angle)
c[i*-]=(double)(pow(e[i+].x-e[i].x,) + pow(e[i+].y-e[i].y,)); ll b1=pow(e[i+].y-e[i].y,)+pow(e[i+].x-e[i].x,),
b2=pow(e[i-].y-e[i].y,)+pow(e[i-].x-e[i].x,),
b3=pow(e[i+].y-e[i-].y,)+pow(e[i+].x-e[i-].x,); c[i*]=1.0*(b1+b2-b3)//sqrt(b1)/sqrt(b2);
}
(*z)=g*;
} int main()
{
int n,m,g1,g2,i,j;
scanf("%d%d",&n,&m);
work(a,c,e,n,&g1);
work(b,d,f,m,&g2);
if (g1!=g2)
{
printf("NO");
return ;
}
for (i=;i<=g2;i++)
d[i+g2]=d[i];
g2<<=; p[]=;
j=;
for (i=;i<=g1;i++)
{
while (j> && fabs(c[j+]-c[i])>minv)
j=p[j];
if (fabs(c[j+]-c[i])<minv)
j++;
p[i]=j;
} j=;
for (i=;i<=g2;i++)
{
while (j> && fabs(c[j+]-d[i])>minv)
j=p[j];
if (fabs(c[j+]-d[i])<minv)
j++;
if (j==g1)
{
printf("YES");
return ;
}
}
printf("NO");
return ;
}
/*
6 5
1 100000000
2 100000000
3 100000000
4 100000000
5 100000000
6 1 2 100000000
6 1
3 100000000
1 100000000
5 100000000
*/
E. The Supersonic Rocket Codeforces Round #502 (in memory of Leopoldo Taravilse, Div. 1 + Div. 2)的更多相关文章
- Codeforces Round #502 (in memory of Leopoldo Taravilse, Div. 1 + Div. 2) E. The Supersonic Rocket
这道题比赛之后被重新加了几个case,很多人现在都过不了了 算法就是先求凸包,然后判断两个凸包相等 我们可以吧凸包序列化为两点距离和角度 角度如果直接拿向量的叉积是不对的,,因为钝角和锐角的叉积有可能 ...
- Codeforces Round #502 (in memory of Leopoldo Taravilse, Div. 1 + Div. 2)
第一次参加cf的比赛 有点小幸运也有点小遗憾 给自己定个小目标 1500[对啊我就是很菜qvq A. The Rank 难度:普及- n位学生 每个学生有四个分数 然鹅我们只需要知道他的分数和 按分数 ...
- Codeforces Round #502 (in memory of Leopoldo Taravilse, Div. 1 + Div. 2) G. The Tree
G. The Tree time limit per test 3 seconds memory limit per test 256 megabytes input standard input o ...
- 【Codeforces Round #502 (in memory of Leopoldo Taravilse, Div. 1 + Div. 2) D】The Wu
[链接] 我是链接,点我呀:) [题意] 给你n个字符串放在multiset中. 这些字符串都是长度为m的01串. 然后给你q个询问 s,k 问你set中存在多少个字符串t 使得∑(t[i]==s[i ...
- Codeforces Round #502
Codeforces Round #502 C. The Phone Number 题目描述:求一个\(n\)排列,满足\(LIS+LDS\)最小 solution 枚举\(LIS\),可证明\(LD ...
- 【Codeforces Round #502 (Div. 1 + Div. 2) 】
A:https://www.cnblogs.com/myx12345/p/9843032.html B:https://www.cnblogs.com/myx12345/p/9843050.html ...
- Codeforces Round #195 A B C 三题合集 (Div. 2)
A 题 Vasily the Bear and Triangle 题目大意 一个等腰直角三角形 ABC,角 ACB 是直角,AC=BC,点 C 在原点,让确定 A 和 B 的坐标,使得三角形包含一个矩 ...
- CodeForces - 1017E :The Supersonic Rocket (几何+KMP,判定凸包是否同构)
After the war, the supersonic rocket became the most common public transportation. Each supersonic r ...
- Codeforces Round #499 (Div. 1)部分题解(B,C,D)
Codeforces Round #499 (Div. 1) 这场本来想和同学一起打\(\rm virtual\ contest\)的,结果有事耽搁了,之后又陆陆续续写了些,就综合起来发一篇题解. B ...
随机推荐
- vue build,本地正常访问,服务器上,网页一刷新是404,解决办法
服务器报错如下图: 此原因,是服务器配置的原因,跟build代码本身无关 以ftp为例,在/etc/nginx/conf.d文件夹下,找到xxx.conf,修改成自己需要的路径即可 位置如下两张图:
- Android开发——RecyclerView特性以及基本使用方法(一)
)关于点击事件,没有像ListView那样现成的API,但是自己封装起来也不难,而且我们使用ListView时,如果item中有可点击组件,那么点击事件的冲突也是一个问题,而在RecyclerView ...
- 【转载】VS配置路径和宏
原文路径:http://blog.csdn.net/puttytree/article/details/7838419 在介绍项目配置之前,先说明两点 1. 项目配置中,最好不要使用相对路径,更不要使 ...
- Django高并发负载均衡
1 什么是负载均衡? 当一台服务器的性能达到极限时,我们可以使用服务器集群来提高网站的整体性能.那么,在服务器集群中,需要有一台服务器充当调度者的角色,用户的所有请求都会首先由它接收,调度者再根据每台 ...
- Django的跨域请求
一 同源策略 同源策略(Same origin policy)是一种约定,它是浏览器最核心也最基本的安全功能,如果缺少了同源策略,则浏览器的正常功能可能都会受到影响.可以说Web是构建在同源策略基础之 ...
- stl源码剖析 详细学习笔记 仿函数
//---------------------------15/04/01---------------------------- //仿函数是为了算法而诞生的,可以作为算法的一个参数,来自定义各种操 ...
- Visual Studio控制台程序输出窗口一闪而过的解决方法
转载大牛的博客,自己也遇到了类似的问题,解决方法很详细,也很管用 刚接触 Visual Studio的时候大多数人会写个Hello World的程序试一下,有的人会发现执行结束后输出窗口会一闪而过 ...
- 阿里云centos 安装禅道
下载 我的阿里云服务器系统是 centos6.8 64 位,下载的禅道版本是 Linux 64位一键安装包(适用于Linux 64位) 由于阿里云服务器没桌面,所以下载用不了浏览器,可考虑在本地下载后 ...
- GitLab篇之Linux下环境搭建
之前公司一直在使用微软的VSS和SVN做为源代码管理工具,考虑到VSS和SVN的局限性,个人一直建议我们应该采用Git来管理我们的源代码.Git的好处不多说相信大家也都知道的.Git不仅仅是一个源代码 ...
- kettle开源项目部署文档
kettle开源项目部署文档 1.kettle简介 kettle是一款国外开源的ETL(Extract Transform Load)工具,纯java编写,可以在Windows.Linux.Unix上 ...