Gym - 100783G:Playing With Geometry (几何 离散化 )
pro:给定规则的多边形,规则是指顶点都在整点上,而且是相互垂直的边的交点。 现在给定两个多边形A,B,问A,B缩小,旋转后是否可以变为同一个图形。
sol:缩小的话,直接离散化即可,就可以去掉没用的部分,旋转的话,可以手动旋转4次。
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<=b;i++)
using namespace std;
const int maxn=;
struct in{
int N,a[maxn],b[maxn],x[maxn],y[maxn];
int lx,ly;
void init()
{
scanf("%d",&N);
rep(i,,N) scanf("%d%d",&a[i],&b[i]);
rep(i,,N) x[i]=a[i],y[i]=b[i];
sort(x+,x+N+); sort(y+,y+N+);
lx=unique(x+,x+N+)-(x+);
rep(i,,N) a[i]=lower_bound(x+,x+lx+,a[i])-x;
ly=unique(y+,y+N+)-(y+);
rep(i,,N) b[i]=lower_bound(y+,y+ly+,b[i])-y;
}
void turn()
{
rep(i,,N){
int t=a[i],q=b[i];
a[i]=q; b[i]=-t+lx+;
}
swap(lx,ly);
}
}A,B;
bool equel()
{
int pos=;
rep(i,,A.N){
if(A.a[i]==B.a[]&&A.b[i]==B.b[]){
pos=i; break;
}
}
if(!pos) return false;
rep(i,pos,A.N)
if(A.a[i]!=B.a[i+-pos]||A.b[i]!=B.b[i+-pos])
return false;
rep(i,,pos-)
if(A.a[i]!=B.a[A.N-pos+i+]||A.b[i]!=B.b[A.N-pos+i+])
return false;
return true;
}
int main()
{
A.init();
B.init();
if(A.N!=B.N) return puts("no"),;
rep(i,,){
if(equel()) return puts("yes"),;
A.turn();
}
puts("no");
return ;
}
Gym - 100783G:Playing With Geometry (几何 离散化 )的更多相关文章
- Codeforces Round #361 (Div. 2) E. Mike and Geometry Problem 离散化 排列组合
E. Mike and Geometry Problem 题目连接: http://www.codeforces.com/contest/689/problem/E Description Mike ...
- PostGIS解析Geometry几何对象
一.Geometry转WKT select st_astext(geom) where tableName; 二.PostGIS常用函数 wkt转geometry st_geomfromtext(wk ...
- Codeforces Round #361 (Div. 2) E. Mike and Geometry Problem 离散化+逆元
E. Mike and Geometry Problem time limit per test 3 seconds memory limit per test 256 megabytes input ...
- PyQt(Python+Qt)学习随笔:Qt Designer中部件的geometry几何属性
geometry属性保存部件相对于其父级对象的位置和大小,Qt实际上是以一个长方形来表示部件的位置和大小的,包括左上角的坐标位置.长度和宽带. 当部件的geometry调整时,部件如果可见将立即接收m ...
- gym 101081 E. Polish Fortress 几何
E. Polish Fortress time limit per test 2.0 s memory limit per test 256 MB input standard input outpu ...
- Gym 100531J Joy of Flight (几何)
题意:你从开始坐标到末尾坐标,要经过 k 秒,然后给你每秒的风向,和飞机的最大速度,问能不能从开始到末尾. 析:首先这个风向是不确定的,所以我们先排除风向的影响,然后算出,静风是的最小速度,如果这都大 ...
- JTS(Geometry)(转)
原文链接:http://blog.csdn.net/cdl2008sky/article/details/7268577 空间数据模型(1).JTS Geometry model (2).ISO Ge ...
- PostGIS 操作geometry方法
WKT定义几何对象格式: POINT(0 0) ——点 LINESTRING(0 0,1 1,1 2) ——线 POLYGON((0 0,4 0,4 4,0 4,0 0),(1 1, 2 1, 2 2 ...
- Northwestern European Regional Contest 2014 Gym - 101482
Gym 101482C Cent Savings 简单的dp #include<bits/stdc++.h> #define inf 0x3f3f3f3f #define inf64 0x ...
随机推荐
- msf下的各种生成payload命令
Often one of the most useful (and to the beginner underrated) abilities of Metasploit is the msfpayl ...
- yaf
一.yaf使用自定义的类 Yaf的library和model的文件命名规则和调用:https://www.cnblogs.com/leedom/p/9396138.html 安装参考: https:/ ...
- tomcat下面web应用发布路径配置 ( 即虚拟目录配置 )
https://blog.csdn.net/AnQ17/article/details/52122236
- Base64 空格,加号问题
缘由: 在一个项目中,app请求tcpdump日志与记录的日志内容不一致 请求%2B 识别成 + 请求 + 识别成 空格 这个在base64解密的时候会出现异常,base64需要的是加号,而不是空格 ...
- Python入门 io篇
简单demo with open('d:/pydemo/pythonStart/fun1.py', 'r') as f: #print(f.read()) while True: line = f.r ...
- windows 添加开始菜单
C:\Users\用户名(为你设置的电脑名称)\AppData\Roaming\Microsoft\Windows\Start Menu C:\ProgramData\Microsoft\Window ...
- 廖雪峰 JavaScript 学习笔记(字符串、数组和对象)
字符串 1.和python一样,也是用' '或" "括起来的字符表示.但多行字符串是用反引号(esc下键)``,与之相对的是Python用''' '''三引号表示: 2.转义字符: ...
- windows 多用户登陆设置
在 “运行”中输入gpedit.msc打开“本地组策略编辑器” | 计算机配置 | 管理模板 | windows 组件 | 远程桌面服务 | 远程桌面会话主机 | 连接 | 限制连接的数量 | 编辑 ...
- JavaScript基础知识点总结
JavaScript----js 全栈课程-------全栈工程师 前端:信息展示,普通用户浏览---前端工程师(html+css:静态页面 js:页面的交互效果) 后台:信息管理,管理员,数据库-- ...
- eclipse添加js智能代码提示
安装重启之后,在项目名上右键 结束