tjut 3492
来源:互联网 发布:王俊煜 知乎 编辑:程序博客网 时间:2024/05/22 11:31
#include <cstdio>#include <cmath>const int maxn = 600 + 10;const double eps = 1e-8;struct Point{ double x, y; Point(double x=0, double y=0):x(x), y(y) {}}p[maxn];int dcmp(double x){ if(fabs(x) < eps) return 0; return x < 0 ? -1 : 1;}Point operator - (const Point& a, const Point& b){ return Point(a.x-b.x, a.y-b.y); }double Cross(const Point& a, const Point& b){ return (a.x*b.y - a.y*b.x); }bool operator == (const Point& a, const Point& b){ return dcmp(a.x-b.x) == 0 && dcmp(a.y-b.y) == 0; }bool intersect(const Point& a, const Point& b, const Point& p1, const Point& p2){ int d1 = dcmp(Cross(b-a, p1-a)); int d2 = dcmp(Cross(b-a, p2-a)); if(d1 == 0 || d2 == 0) return true; if(d1 * d2 < 0) return true; return false;}int main(void){ //freopen("3492in.txt", "r", stdin); int T; scanf("%d", &T); while(T--) { int n; scanf("%d", &n); for(int i = 0; i < 2*n-1; i += 2) scanf("%lf%lf%lf%lf", &p[i].x, &p[i].y, &p[i+1].x, &p[i+1].y); bool exist = false; bool issame = true; for(int i = 0; i < 2*n-1 && !exist; ++i) { for(int j = i+1; j < 2*n && !exist; ++j) { if(p[i] == p[j]) continue; issame = false; int k; for(k = 0; k < 2*n; k += 2) if(!intersect(p[i], p[j], p[k], p[k+1])) break; if(k == 2 * n) exist = true; } } if(exist || issame) puts("Yes"); else puts("No"); } return 0;}
0 0
- tjut 3492
- tjut 5289
- tjut 5288
- tjut 5294
- tjut 2586
- tjut 5296
- tjut 5297
- tjut 5299
- tjut 5384
- tjut 5387
- tjut 5386
- tjut 5381
- tjut 5400
- tjut 5399
- tjut 5396
- tjut 5398
- tjut 5412
- tjut 5410
- 微信Android热补丁实践演进之路
- windows安装matplotlib
- 关于DOSGI-CXF整合到SpringDM上的解决办法
- iOS 获取 当前设备 可用内存 及当前 应用 所占内存 (转)
- Android连点器(adb)
- tjut 3492
- iOS Xcode 打包IPA问题集锦
- Hadoop常用命令
- 数据库的简单操作1
- PHP中使用memcache存储session的三种配置方法
- android 通信
- java版求字符串的最大公共子串
- 字符串处理总结之一(C#String类)
- CSU - 1111 三家人