BZOJ2494 Triangles and Quadrangle
一道非常"简单"的计算几何题。。。
题意:给你两个三角形和一个四边形,问你能否用这两个三角形拼成这个四边形
首先。。。四边形可能是凹四边形。。。需要判断一下。。。这个比较简单直接分成两部分即可。。。
然后。。。四边形可能会退化成三角形。。。那就需要两个三角形拼起来的时候某两个角之和为180°
最后暴力一下如何划分四边形即可。。。
写的真是开心,还好一遍A了QAQ
/**************************************************************
Problem: 2494
User: rausen
Language: C++
Result: Accepted
Time:8 ms
Memory:820 kb
****************************************************************/ #include <cstdio>
#include <cmath>
#include <algorithm> using namespace std;
typedef double lf; template <class T> inline T sqr(const T &x) {
return x * x;
} template <class T> inline int sgn(const T &x) {
const T eps = 1e-;
if (fabs(x) < eps) return ;
return x < ? - : ;
} struct point {
lf x, y;
point() {}
point(lf _x, lf _y) : x(_x), y(_y) {} inline point operator + (const point &p) const {
return point(x + p.x, y + p.y);
}
inline point operator - (const point &p) const {
return point(x - p.x, y - p.y);
}
inline lf operator * (const point &p) const {
return x * p.y - y * p.x;
}
inline point operator * (const lf &d) const {
return point(x * d, y * d);
}
inline void get() {
scanf("%lf%lf", &x, &y);
}
friend inline lf dis2(const point &p) {
return sqr(p.x) + sqr(p.y);
}
friend inline lf dis(const point &p) {
return sqrt(dis2(p));
}
} t[][], p[]; inline bool check(const point &a, const point &b, const point &c, const int &p) {
static lf T1[], T2[];
static int i;
T1[] = dis(a - b), T1[] = dis(b - c), T1[] = dis(c - a);
for (i = ; i < ; ++i)
T2[i] = dis(t[p][i] - t[p][i + ]);
sort(T1, T1 + ), sort(T2, T2 + );
for (i = ; i < ; ++i)
if (sgn(T1[i] - T2[i]) != ) return ;
return ;
} inline point get_cross(const point &a, const point &b, const point &c, const point &d) {
static lf rate;
rate = / ( - ((d - c) * (b - c)) / ((d - c) * (a - c)));
return (b - a) * rate + a;
} int main() {
int T, icase, i, j, f;
lf di[], d1;
point p1, a, b, c, d, e;
scanf("%d", &T);
for (icase = ; icase <= T; ++icase) {
f = ;
for (i = ; i < ; ++i) t[][i].get(), t[][i + ] = t[][i];
for (i = ; i < ; ++i) t[][i].get(), t[][i + ] = t[][i];
for (i = ; i < ; ++i) p[i].get(), p[i + ] = p[i]; for (i = ; i < ; ++i)
di[i] = dis(t[][i] - t[][i + ]), di[i + ] = dis(t[][i] - t[][i + ]);
if (((p[] - p[]) * (p[] - p[])) * ((p[] - p[]) * (p[] - p[])) < ) {
if (check(p[], p[], p[], ) && check(p[], p[], p[], )) f = ;
if (check(p[], p[], p[], ) && check(p[], p[], p[], )) f = ;
}
if (((p[] - p[]) * (p[] - p[])) * ((p[] - p[]) * (p[] - p[])) < ) {
if (check(p[], p[], p[], ) && check(p[], p[], p[], )) f = ;
if (check(p[], p[], p[], ) && check(p[], p[], p[], )) f = ;
} for (i = ; i < ; ++i) {
a = p[i], b = p[i + ], c = p[i + ], d = p[i + ];
if (((b - a) * (c - a)) * ((b - a) * (d - a)) < ) {
e = get_cross(a, b, c, d);
if (check(a, d, e, ) && check(b, c, e, )) f = ;
if (check(a, d, e, ) && check(b, c, e, )) f = ;
}
}
for (i = ; i < ; ++i) if (sgn((p[i + ] - p[i]) * (p[i + ] - p[i])) == ) {
d1 = dis(p[i + ] - p[i]);
for (j = ; j < ; ++j) if (d1 >= di[j]) {
p1 = p[i + ] - p[i];
p1 = p1 * (di[j] / d1) + p[i];
if (check(p[i + ], p[i], p1, ) && check(p[i + ], p[i + ], p1, )) f = ;
if (check(p[i + ], p[i], p1, ) && check(p[i + ], p[i + ], p1, )) f = ;
}
}
printf("Case #%d: %s\n", icase, f ? "Yes" : "No");
}
return ;
}
BZOJ2494 Triangles and Quadrangle的更多相关文章
- bzoj AC倒序
Search GO 说明:输入题号直接进入相应题目,如需搜索含数字的题目,请在关键词前加单引号 Problem ID Title Source AC Submit Y 1000 A+B Problem ...
- Count the number of possible triangles
From: http://www.geeksforgeeks.org/find-number-of-triangles-possible/ Given an unsorted array of pos ...
- [ACM_搜索] Triangles(POJ1471,简单搜索,注意细节)
Description It is always very nice to have little brothers or sisters. You can tease them, lock them ...
- acdream.Triangles(数学推导)
Triangles Time Limit:1000MS Memory Limit:64000KB 64bit IO Format:%lld & %llu Submit Stat ...
- UVA 12651 Triangles
You will be given N points on a circle. You must write a program to determine how many distinctequil ...
- Codeforces Gym 100015F Fighting for Triangles 状压DP
Fighting for Triangles 题目连接: http://codeforces.com/gym/100015/attachments Description Andy and Ralph ...
- Codeforces Round #309 (Div. 1) C. Love Triangles dfs
C. Love Triangles Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/553/pro ...
- Codeforces Round #308 (Div. 2) D. Vanya and Triangles 水题
D. Vanya and Triangles Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/55 ...
- Project Euler 94:Almost equilateral triangles 几乎等边的三角形
Almost equilateral triangles It is easily proved that no equilateral triangle exists with integral l ...
随机推荐
- How to run an manually installed program from terminals in Linux / Ubuntu
Say we have installed qt programs and we want to run qtcreator from the command line. What we need h ...
- Spark Streaming官方文档学习--上
官方文档地址:http://spark.apache.org/docs/latest/streaming-programming-guide.html Spark Streaming是spark ap ...
- Codeforces Round #287 (Div. 2) C. Guess Your Way Out! 思路
C. Guess Your Way Out! time limit per test 1 second memory limit per test 256 megabytes input standa ...
- 高效使用Vector
参考网页: http://www.cnblogs.com/biyeymyhjob/archive/2013/05/11/3072893.html#undefined 1.初始化的时候,最好先用rese ...
- 抓包工具__Windows
我常使用的: 1. SoftPerfect Network Protocol Analyzer 2. fiddler . fiddler2 3.
- QQ游戏_相关
1. 侍魂: 1.1. ...\QQGame ...\QQGame\samsho2 1.2. C:\Users\xx\AppData\Roaming\Tencent\QQGAME\Download C ...
- poj2002Squares(点集组成正方形数)
链接 可以枚举两个点,因为是正方形两外两点可以由已知求出,据说可以根据三角形全等求出下列式子,数学渣不会证... 已知: (x1,y1) (x2,y2) 则: x3=x1+(y1-y2) y ...
- VideoView
[1]这个控件就是对surfaceview 和 meidiaplayer进行封装 [2]meidiaplayer 播放视频他只支持 3gp MP4格式
- Java Ant build.xml详解
1,什么是antant是构建工具2,什么是构建概念到处可查到,形象来说,你要把代码从某个地方拿来,编译,再拷贝到某个地方去等等操作,当然不仅与此,但是主要用来干这个3,ant的好处跨平台 --因为 ...
- Java编程思想笔记
打好java基础 后续会增加相应基础笔试题 目录如下 1 对象导论2 一切都是对象3 操作符4 控制执行流程5 初始化与清理6 访问控制权限7 复用类8 多态9 接口10 内部类11 持有对象12 通 ...