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 ...
随机推荐
- 20155308 《网络攻防》 Exp2 后门原理与实践
20155308 <网络攻防> Exp2 后门原理与实践 学习内容:使用nc实现win,mac,Linux间的后门连接 :meterpraeter的应用 :MSF POST 模块的应用 学 ...
- Vue 项目集合
饿了么安全应急响应中心 饿了么招聘 饿了么前端 · GitHub 稀土掘金 异乡好居 明星垂搜 广州建管 基于Vue.js的数据统计系统(一) 基于Vue.js的数据统计系统(二) 基于Vue.js的 ...
- VS与Opencv的亲密接触之安装配置过程
最近想把FPGA采集的图像,上传到上位机显示,看到Opencv能帮大忙,所以就折腾折腾! 我用的是VS2012和opencv-2.4.10-2.4.10(目前的最新版本),那个版本无所谓,本文都将适用 ...
- 【Java框架型项目从入门到装逼】第十一节 用户新增之把数据传递到后台
让我们继续来做"主线任务",这一节,我们来做具体的用户新增功能.首先,为了简单起见,我把主页面改了一些,改的是列表那一块.删去了一些字段,和数据库表对应一致: 现在,我们要实现一个 ...
- 通过实例来理解paxos算法
背景 Paxos算法是莱斯利·兰伯特(Leslie Lamport,就是 LaTeX 中的”La”,此人现在在微软研究院)于1990年提出的一种基于消息传递的一致性算法.由于算法难以理解起初并没有 ...
- 在windows10上安装caffe和tensorflow
最近在Windows10上安装了caffe和tensorflow,折腾了好久.在此记录一下. 安装caffe的过程已在另一篇博客中进行了记录,在此不再赘述.而tensorflow也是非常简单的,也不再 ...
- 区块链学习:Windows下搭建以太坊私有链环境
一:安装geth客户端 Windows要求必须是64位系统,从官方网站下载编译好的win64客户端,下载解压后只有一个Geth.exe问价,运行安装即可,下载地址如下: https://github. ...
- PAT甲题题解-1065. A+B and C (64bit) (20)-大数溢出
第一眼以为是大数据,想套个大数据模板,后来发现不需要.因为A.B.C的大小为[-2^63, 2^63],用long long 存储他们的值和sum. 接下来就是分类讨论:如果A > 0, B & ...
- LeetCode 463. Island Perimeter岛屿的周长 (C++)
题目: You are given a map in form of a two-dimensional integer grid where 1 represents land and 0 repr ...
- 第二个spring冲刺第5天
针对与昨天的讨论内容,今天进行了开会研讨给意见. 在今天中有了点进展,各方面都有改善,离程序的完成度又前进了一大步.