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 ...
随机推荐
- 20155318 《网络攻防》 Exp8 Web基础
20155318 <网络攻防> Exp8 Web基础 基础问题 什么是表单? HTML表单用于收集用户输入,用元素定义,包含不同类型的input元素.复选框.单选按钮.提交按钮等等.一个表 ...
- WinRT IO相关整理
虽然一般UWP开发还是依赖.Net for UWP,但有时还是需要调用WinRT API.特别是在IO部分,WinRT有着和.Net似曾相识但又不尽相同的接口.在此对经常用到的一些地方进行一下整理. ...
- Python 语言简介
Python是一种计算机程序设计语言.你可能已经听说过很多种流行的编程语言,比如非常难学的C语言,非常流行的Java语言,适合初学者的Basic语言,适合网页编程的JavaScript语言等等. 那P ...
- IP 解析器(IpParser) test 和 生产环境 实现
注意:之前我maven居然没有引入 StringUtils 的包,然后引入了一个路径类似,但其实包路径不一样的 StringUtils ,居然是划掉的状态,像这样 StringUtils ,这个其实不 ...
- Solr 后台查询实例 (工作备查)
有时间再进行整理package xxx.service.impl; import java.util.HashMap; import java.util.Map; import java.util.M ...
- 如何解决markdown中图片上传的问题
1.第一种方式(图床) 1.1 google中的插件-新浪微博图床 2.第二种方式,操作流程如下 2.1 下载一个有道云笔记客户端 2.2 然后把图片通过有道云笔记分享出来,见下动态图 3.总结一下 ...
- mac10.12.6系统使用cmake安装opencv3.3.0+opencv_contrib-3.3.0
brew与cmake brew安装 /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/ins ...
- laravel从5.2到5.5从入门到精通视频教程共16套
laravel从5.2到5.5从入门到精通视频教程共16套,大部分都是实战项目比如P2P.博客.短网址.知乎门户.app软件开发.微信商城实战等 课程目录: 01.Laravel框架从入门到精通02. ...
- strongSwan配置、运行及测试
版本信息:strongSwan v5.7.2 1. 编译 tar xvf strongswan-5.7.2.tar.gz ./configure --prefix=/usr/ --sysco ...
- Kubernetes并发控制与数据一致性的实现原理
在大型分布式系统中,定会存在大量并发写入的场景.在这种场景下如何进行更好的并发控制,即在多个任务同时存取数据时保证数据的一致性,成为分布式系统必须解决的问题.悲观并发控制和乐观并发控制是并发控制中采用 ...