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 ...
随机推荐
- Bytom信息上链教程
比原项目仓库: Github地址:https://github.com/Bytom/bytom Gitee地址:https://gitee.com/BytomBlockchain/bytom 用比原链 ...
- IdentityServer4服务器配置
Session认证和JWT(Json Web Token) Token认证就是基于JWT 1.Session认证 1. 用户输入其登录信息 2. 服务器验证信息是否正确,并创建一个session,然后 ...
- Vue 兼容 IE9 全功能正常使用的全面解决方案
https://blog.csdn.net/VhWfR2u02Q/article/details/80863626
- ASM ClassReader failed to parse class file - probably due to a new Java class file version that isn't supported yet………
在照着这里例子学习ssm时,在部署阶段遇到了这个问题“ASM ClassReader failed to parse class file - probably due to a new Java c ...
- Java操作MongoDB:连接&增&删&改&查
1.连接 ①方式一 MongoClientOptions.Builder builder = MongoClientOptions.builder(); //可以通过builder做各种详细配置 Mo ...
- haoop fs 命令
Hadoop fs 命令详解 参考文档:https://hadoop.apache.org/docs/r2.7.1/hadoop-project-dist/hadoop-common/FileSy ...
- erlang 笔记(06/03/02)
1 .同时打开的端口数量限制(Open ports) erlang:system_info(port_limit)查询 可以通过环境变量ERL_MAX_PORTS修改,或者配置erlang启动参数(标 ...
- 学习GT一书前九章的体会
学习Gilbarg和Trudinger一书前九章的体会 本书第二章,调和函数的基本性质进行展示.特别的对比较定理有深刻的阐述以及Perron方法的基本说明,并对Wiener准则作了简要说明. 第三章的 ...
- yii2 adminlte后台搭建
加载第三方扩展, composer require dmstr/yii2-adminlte-asset "2.*" composer require mdmsoft/yii2-ad ...
- 斜率优化dp的总结
放在了我的另一个博客上面 斜率优化dp的总结(多刷新几次才打得开)