解题报告-HDU 3662 (三维凸包)

三维凸包之增量算法 算法工作过程: 选取点集中的四个点构成一个初始的四面体: 选两个点p1, p2,再选一个点p3,p3和p1, p2不在同一条直线上,这样形成了一个面。再选一个点,不在同一个面上,形成一个四面体。 然后继续研究剩余的点: 点在四面体内部,略过。 点在四面体外部,删除此点能“看见”的面,扩大凸包体积。 POJ 3528 Ultimate Weapon http://poj 阅读详情

暂时还没看懂,先把模板记下来:

#include <iostream>
#include <cstring>
#include <algorithm>
#include <cstdio>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
using namespace std;
#define eps 1e-7
#define MAXV 310
struct pt {
	double x, y, z;
	pt() {
	}
	pt(double _x, double _y, double _z) :
	x(_x), y(_y), z(_z) {
	}
	pt operator -(const pt p1) {
		return pt(x - p1.x, y - p1.y, z - p1.z);
	}
	pt operator *(pt p) {
		return pt(y * p.z - z * p.y, z * p.x - x * p.z, x * p.y - y * p.x);
	}
	double operator ^(pt p) {
		return x * p.x + y * p.y + z * p.z;
	}
};
struct _3DCH {
	struct fac {
		int a, b, c;
		bool ok;
	};
	int n;
	pt P[MAXV];
	int cnt;
	fac F[MAXV*8];
	int to[MAXV][MAXV];
	double vlen(pt a) {
		return sqrt(a.x * a.x + a.y * a.y + a.z * a.z);
	}
	double area(pt a, pt b, pt c) {
		return vlen((b - a) * (c - a));
	}
	double volume(pt a, pt b, pt c, pt d) {
		return (b - a) * (c - a) ^ (d - a);
	} // 四面体有向体积*6
	double ptof(pt &p, fac &f) {
		pt m = P[f.b] - P[f.a], n = P[f.c] - P[f.a], t = p - P[f.a];
		return (m * n) ^ t;
	}
	void deal(int p, int a, int b) {
		int f = to[a][b];
		fac add;
		if (F[f].ok) {
			if (ptof(P[p], F[f]) > eps)
				dfs(p, f);
			else {
				add.a = b, add.b = a, add.c = p, add.ok = 1;
				to[p][b] = to[a][p] = to[b][a] = cnt;
				F[cnt++] = add;
			}
		}
	}
	void dfs(int p, int cur) {
		F[cur].ok = 0;
		deal(p, F[cur].b, F[cur].a);
		deal(p, F[cur].c, F[cur].b);
		deal(p, F[cur].a, F[cur].c);
	}
	bool same(int s, int t) {
		pt &a = P[F[s].a], &b = P[F[s].b], &c = P[F[s].c];
		return fabs(volume(a, b, c, P[F[t].a])) < eps && fabs(volume(a, b, c,
			P[F[t].b])) < eps && fabs(volume(a, b, c, P[F[t].c])) < eps;
	}
	void construct() {
		int i;
		cnt = 0;
		if (n < 4)
			return;
		
		bool sb = 1;
		for (i = 1; i < n; i++) {
			if (vlen(P[0] - P[i]) > eps) {
				swap(P[1], P[i]);
				sb = 0;
				break;
			}
		}
		if (sb)
			return;
		sb = 1;
		for (i = 2; i < n; i++) {
			if (vlen((P[0] - P[1]) * (P[1] - P[i])) > eps) {
				swap(P[2], P[i]);
				sb = 0;
				break;
			}
		}
		if (sb)
			return;
		sb = 1;
		for (i = 3; i < n; i++) {
			if (fabs((P[0] - P[1]) * (P[1] - P[2]) ^ (P[0] - P[i])) > eps) {
				swap(P[3], P[i]);
				sb = 0;
				break;
			}
		}
		if (sb)
			return;
		fac add;
		for (i = 0; i < 4; i++) {
			add.a = (i + 1) % 4, add.b = (i + 2) % 4, add.c = (i + 3) % 4, add.ok
				= 1;
			if (ptof(P[i], add) > 0)
				swap(add.b, add.c);
			to[add.a][add.b] = to[add.b][add.c] = to[add.c][add.a] = cnt;
			F[cnt++] = add;
		}
		for (i = 4; i < n; i++) {
			for (int j = 0; j < cnt; j++) {
				if (F[j].ok && ptof(P[i], F[j]) > eps) {
					dfs(i, j);
					break;
				}
			}
		}
		int tmp = cnt;
		cnt = 0;
		for (i = 0; i < tmp; i++) {
			if (F[i].ok) {
				F[cnt++] = F[i];
			}
		}
	}
	double area() {
		double ret = 0.0;
		for (int i = 0; i < cnt; i++) {
			ret += area(P[F[i].a], P[F[i].b], P[F[i].c]);
		}
		return ret / 2.0;
	}
	double volume() {
		pt O(0, 0, 0);
		double ret = 0.0;
		for (int i = 0; i < cnt; i++) {
			ret += volume(O, P[F[i].a], P[F[i].b], P[F[i].c]);
		}
		return fabs(ret / 6.0);
	}
	int facetCnt_tri() {
		return cnt;
	}
	int facetCnt() {
		int ans = 0;
		for (int i = 0; i < cnt; i++) {
			bool nb = 1;
			for (int j = 0; j < i; j++) {
				if (same(i, j)) {
					nb = 0;
					break;
				}
			}
			ans += nb;
		}
		return ans;
	}
};
_3DCH hull;
int main() {
	while (~scanf("%d", &hull.n)) {
		for (int i = 0; i < hull.n; i++)
			scanf("%lf%lf%lf", &hull.P[i].x, &hull.P[i].y, &hull.P[i].z);
		hull.construct();
		printf("%d\n", hull.facetCnt());
	}
	return 0;
}


三、使用HM进行简单的视频隐写demo 三、使用HM进行简单的视频隐写前言一、实验环境二、实验思路三、实验过程3.1 提取原始载体3.2 使用LSB隐写算法进行隐写3.3 放回含密载体3.4 提取含密载体3.5 使用LSB提取算法进行比对四、碰到的问题以及解决思路4.1 块的结构体发生变化4.1.1 产生的原因4.1.2 解决方法4.2 一个有趣的现象4.2.1 产生的原因4.3 视频产生较大失真4.3.1 产生的原因4.3.2 解决方法五、总结 前言 在前两篇博客中介绍了基于HEVC/H.265视频编解码器的视频隐写的基本思路,本文将详细记录 阅读详情

相关推荐

Verilog仿真时读取bin文件模拟输入数据流,将输出数据流写入bin文件

需要关注的是,一般会省略文件起始地址和读取长度,那么mem为多大,就会从文件中读取多大的数据出来填充mem。如果只需要读取一次文件,那么代码到此就结束了,但是如果还需要每一帧都读取该文件转换为数据流,则在循环里判断新的一帧信号是否到来,在新的一帧再次打开一次文件,从头开始读取数据。

qq_41137205的博客 2772

【HDU 3662】3D Convex Hull

http://acm.hdu.edu.cn/showproblem.php?pid=3662 求给定空间中的点的三维凸包上有多少个面。 用增量法,不断加入点,把新加的点能看到的面都删掉,不能看到的面与能看到的面的棱与新点相连构成一个新的三角形面。 这样的面全都是三角形,注意最后统计答案时要把重合的面算成一个。 时间复杂度\(O(n^2)\)。 #include<cmath> ...

as2886089的博客 233

Docker容器化部署Ceph集群:从零搭建高可用分布式存储

本文详细介绍了如何使用Docker容器化部署Ceph集群,从零搭建高可用分布式存储系统。通过环境一致性、快速扩容和资源隔离等优势,Docker显著提升了Ceph集群的部署效率和运维便捷性。文章涵盖硬件规划、镜像选择、单节点部署、多节点扩展及性能调优等实战内容,帮助开发者快速掌握分布式存储系统的容器化部署技巧。

weixin_29081101的博客 422

hdu 3662

题意:三维里一堆点里面找一个多边形包括所有点 思路:裸的三维凸包模板。网上的模板都是一样的,我把上交的ACM国际大学生程序设计竞赛上的三维凸包敲了一下,因为缺少必要的函数,所以一开始迟迟不过,后来套用了一些函数,就能过了,总得来说,上交写的模板不会是错的,这么厉害的学校不会犯这种错误的。附上代码#include #include #include #include #include #inclu

zjbh89757的专栏 469

EEVDF调度算法核心实现解析(一)

本文深入解析Linux kernel 6.6引入的EEVDF调度算法核心实现,详细讲解其基于虚拟截止时间(virtual deadline)的进程挑选机制和红黑树优化设计。通过代码实例展示算法如何平衡系统响应速度与公平性,特别适合需要优化Linux系统性能的开发者参考。

weixin_42522953的博客 477

SWD下载调试接口原理深度剖析

作为ARM嵌入式工程师,下载调试器都应该知道,但你真正了解SWD如何下载调试的么?ARM 芯片通过什么物理接口和什么方式连接完全取决于芯片Debug子系统的架构如何?

zhuwade的博客 1万+

hdu 3662 3D Convex Hull

三维凸包,用递增法每次扩展一个四面体,去掉覆盖面 #include #include #include #include using namespace std; const int MAXN=550; const double eps=1e-8; struct Point { double x,y,z; Point(){} Point(double xx,doub

solotzg 718

ROS从入门到精通6-2:gmapping激光建图与自定义建图功能包

本文用Turtlebot3实例直观介绍激光建图概念,并实现自定义建图功能包(自动建图与键盘手动控制建图)

FRIGIDWINTER的博客 2662

hdu3662 +3D Convex Hull+三维凸包的表面多边形个数

Description There are N points in 3D-space which make up a 3D-Convex hull*. How many faces does the 3D-convexhull have? It is guaranteed that all the points are not in the same plane.In case you don’t

xtulollipop 1110

YOLOv11 | 一文带你深入理解ultralytics最新作品yolov11的创新 | 训练、推理、验证、导出 (附网络结构图)

ultralytics发布了最新的作品YOLOv11,这一次YOLOv11的变化相对于ultralytics公司的上一代作品YOLOv8变化还是很大的(YOLOv9、YOLOv10均不是ultralytics公司作品),其中改变的位置涉及到C2f变为C3K2,在SPPF后面加了一层类似于注意力机制的C2PSA,还有一个变化大家从yaml文件是看不出来的就是它的检测头内部替换了两个DWConv,在损失函数方面就没有变化了还是采用的CIoU作为边界框回归损失,下面带大家深入理解一下ultralytics最新作品

Snu77的博客 18万+

【系统架构设计师】模拟预测试卷十 - 案例分析(完整结构)

本文为系统架构设计师考试模拟试题及参考答案,包含五个专题:质量属性(必答)、信息系统架构设计、嵌入式系统架构设计、云原生架构设计、面向服务架构设计(SOA)。试题一聚焦非功能需求与质量属性映射,如性能、可修改性、一致性等;其余选答题分别涉及分层架构设计(如嵌入式实时控制)、云原生会话管理、服务化治理(如契约设计、熔断策略)等核心架构场景,涵盖战术应用、权衡分析及解决方案设计。参考答案提供关键要点,例如离线借还的冲突解决、服务编排与共享服务的区分、嵌入式硬实时保护的必要性等,适用于备考实战演练。

数据知道的博客 251

Hdu 3662 3D Convex Hull(三维凸包)

题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=3662 思路:三维凸包模板。 #include #include #include #include #include #define PR 1e-8 #define N 510 using namespace std; struct TPoint { double x,y,z;

哆啦AC梦的博客 2284

Camera2Demo

在Camera2 的基础上进行封装,使得Camera2一堆初始化逻辑与Activity分离,降低耦合度,完成预览拍照并保存的操作

POJ 3528 三维凸包模板

#include #include #include #include using namespace std; #define inf 0x7fffffff #define max(a,b) (a>b?a:b) #define min(a,b) (a<b?a:b) #define eps 1e-7 #define MAXV 505 //三维点 struct pt { doubl

Christine的专栏 1180

精雕软件(JDpaint) 5.5 绿色版

精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版

efm32 入门.pdf

本PDF共计22页,介绍的是操作驱动API,下载与否自己斟酌。

HDU 3662 3D Convex Hull(三维凸包面的个数)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3662 题意:求三维凸包面的个数。 思路:模板。 struct Point { double x,y,z; Point() {} Point(double _x,double _y,double _z) { x=_x; y=_y;...

weixin_33910137的博客 185

IMSL CNL 7.0.0 (x86-64)Crack

IMSL CNL 7.0.0 (x86-64)Crack intel的算法库破解文件,这是C++版本的破解文件

hdu 3662 3D Convex Hull (三维凸包模板)

/* 出三维空间中的n个顶点,求解由这n个顶点构成的凸包表面的多边形个数. 增量法求解: 首先任选4个点形成的一个四面体,然后每次新加一个点,分两种情况: 1> 在凸包内,则可以跳过 2> 在凸包外,找到从这个点可以"看见"的面,删除这些面,然后对于一边没有面的线段, 和新加的这个点新建一个面,至于这个点可以看见的面,就是求出这个面的方程(可以直接求法向量). 下面是三维凸包的模板 */ #

苍竹林 731

poj3528,hdu3662三维凸包模板题

#include #include #include #include #include #include #define PR 1e-8 #define N 510 using namespace std; struct TPoint { double x,y,z; TPoint() {} TPoint(double _x,double _y,double _z):x(_

Everything can be done! 274

【HDU3662】3D Convex Hull(三维凸包)

传送门 题解: 三维凸包板子题,所有面全部用三角形来记录,最后判断的时候去一下重就行了。 代码: #include<bits/stdc++.h> #define ll long long #define re register #define db double #define cs const using std::cerr; using std::cout; cs int ...

zxyoi_dreamer的博客(不定期诈尸) 407

POJ 3528 hdu 3662 三维凸包模板题

Ultimate Weapon Time Limit: 2000MS   Memory Limit: 131072K Total Submissions: 2007   Accepted: 958 Description In year 2008 of the Cosmic Calendar, the Aliens send a hu

_rabbit的专栏 1102

HDU 3662 三维凸包表面多边形个数

题意:求三维凸包表面多边形个数。 我是来试模板的= = #include #include #include #include #include using namespace std; const int MAXN=1050; const double eps=1e-8; struct Point { double x,y,z; Point() {} Point(d

韩小侠的专栏 已迁移至lssea.com 963

三维凸包模板_HDU 3662 3D Convex Hull

HDU 3662 3D Convex Hull http://acm.hdu.edu.cn/showproblem.php?pid=3662 #include #include #include #include #include #include #include #include #include #include #include #include #in

Confidence的专栏 1578

HDU 3662 3D Convex Hull(三维凸包表面多边形个数)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3662 这个题目我的三维凸包模板竟然有问题,改后AC,模板题留个模板吧! #include #include #include #include #include #include using namespace std; const int MAXN=1001; const int N

sunrain的专栏 1274

hdu3662 三维凸包的面的个数

#include #include #include #include using namespace std; #define N 600 #define EPS 1e-8 struct tpoint { double x,y,z; tpoint(){} tpoint(double _x,double _y,double _z):x(_x),y(_y),z(_z){} tpoint op

lyc 699

hdu3662 3D Convex Hull(三维凸包【三维计算几何基本操作)

题目连接 分析: 三维凸包模板 瞧好了基本操作 三维和二维简直不是一个级别的。。。orz #include&lt;bits/stdc++.h&gt; using namespace std; const double eps=1e-8; const int N=503; struct node{ double x,y,z; node (double xx=0,do...

Coco_T的博客 2007

【三维凸包】模板题

1.关于三维凸包的模板。拿的是kuangbin聚聚的。具体的题目有:HDU4273,HDU3662,POJ3528,POJ3682等。模板如下: const int MAXN = 550; const double eps = 1e-8; struct Point { double x, y, z; Point() {} Point(double xx, double yy, dou...

YG爱木木 232

三维凸包模板 HDU 3662 3D Convex Hull

二维的搞得差不多了就想搞三维的,但是网上搜了半天只找到两道题目,蛋疼。。 /*给出三维空间中的n个顶点,求解由这n个顶点构成的凸包表面的多边形个数.增量法求解:首先任选4个点形成的一个四面体,然后每次新加一个点,分两种情况: 1> 在凸包内,则可以跳过 2> 在凸包外,找到从这个点可以"看见"的面,删除这些面,然后对于一边没有面的线段,和新加的...

weixin_30815427的博客 135
上一篇: 解题报告-HDU 2892 (计算几何)
下一篇: 2013-05-12 广东省赛之行
WellerZhao
博客等级 码龄15年 11粉丝 28原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值