- 博客(18)
- 收藏
- 关注
原创 判断点是否在多边形内
角度和判定法bool isInPolygon_angle( Point P,Point *p,int n ){ double angle = 0; for( int i = 0; i < n-1; i ++ ) { angle += Angle( p[i] - P,p[i+1] - P ); } angle += Angle( p[n-1] - P,p[0] - P )
2013-12-27 21:34:06 395
原创 二维几何基础
#include#include//常用定义const double eps = 1e-10;struct Point{ double x,y; Point( double x = 0,double y = 0 ): x(x),y(y) {}};typedef Point Vector;Vector operator + ( Vector A,Vector B ) { retu
2013-12-27 20:31:48 437
原创 HDU-2007 Scrambled Polygon 极角排序
题目地址题意:就是将所给点按凸包顺序输出,从原点开始。分析:其实就是将除原点外的点进行极角排序。#include#include#includeusing namespace std;const int maxn = 55;int n,r;struct Point{ double x,y; Point( double x = 0,double y
2013-12-21 17:46:22 341
原创 HDU-2108 Shape of HDU
判断多边形是凸还是凹 即判断凸包点数是否等于原点数#include#include#includeusing namespace std;const int maxn = 1005;#define PI 3.14159265int n,r;struct Point{ double x,y; Point( double x = 0,double y = 0 ): x(
2013-12-21 17:00:53 424
原创 HDU-1348 Wall 凸包
#include#include#includeusing namespace std;const int maxn = 1005;#define PI 3.14159265int n,r;struct Point{ double x,y; Point( double x = 0,double y = 0 ): x(x),y(y) { }}point[maxn],ch[max
2013-12-21 16:40:07 428
原创 分土地
一块土地,在边界上选n个点,并两两头尾相连,问最多能把土地分成几个部分?小白书:P86 最优方案不会让任意三条边交与一点。欧拉公式: V - E + F = 2; V是顶点数(所以线段端点加交点数) E是边数(n段线段加上被切成的段数) F是面数(土地块数加上土地边界外的无穷大的面) 答案即为 E-V+1V = n + n/4 * 求和(
2013-12-17 12:53:09 681
原创 三角形有向面积 + 判断点是否在三角形内部
公式: 以三角形两边的平行四边形面积等于两边向量叉乘三角形三个顶点如果顺时针那么面积为负,逆时针为正判断点o是否在三角形abc内部当且仅当 Sabc == Soab + Sobc + Soac#include#include#include#include#includeusing namespace std;const int maxn = 1005;c
2013-12-17 12:26:33 1106
原创 FAFU-1410 九数矩阵 康拓展开
http://acm.fafu.edu.cn/problem.php?id=1410类似八数码问题 用整形存状态4秒 康拓展开式1秒#include#include#include#include#includeusing namespace std;const int maxn = 1005;const int inf = 1<<30;int n;int f[10]
2013-12-13 14:49:16 684
转载 KMP算法详解
转载 http://blog.csdn.net/niushuai666/article/details/6960985一. 简单匹配算法先来看一个简单匹配算法的函数:[cpp] view plaincopyint Index_BF ( char S [ ], char T [ ], int pos ) { /* 若串
2013-12-10 08:58:55 388
原创 POJ-1236 Network of Schools 强连通+缩点
题意: N个学校有网络相连 每个学校维护着一个学校列表,它向学校列表中的学校发布软件;(单向发布); 任务A: 为使每个学校都能通过网络收到软件,至少需要准备多少份软件拷贝 任务B:想确保给任意一个学校发布一个软件。该软件能发布到网络中的每个学校。为达到这个目标,必须在列表中添加新的成员,计算需要添加新成员的最小数目。思路:
2013-12-09 16:41:37 491
原创 POJ-2186 Popular Cows 强连通 + 缩点
http://poj.org/problem?id=2186我们求强连通分量时,给每个顶点做一个标记,标记该顶点属于哪个强联通分量,然后属于同一个强连通分量的点就可以看作同一个点了。这就是所谓的“缩点” 此题用了个定理 :有向无环图(DAG)中,从任意一个点出发,必定可以到达某一个出度为0的点。 这个不用证明,直观想一下就行了。 因为无环,所以从一
2013-12-08 20:06:22 562
原创 2013长春现场赛
2013长春现场赛水题 虽然我想不出思路看别人题解懂的 #include#include#include#includeusing namespace std;const int maxn = 105;const int inf = 1<<30;int n,m,pos;__int64 s[maxn],p[maxn],price[maxn];int find( __i
2013-12-07 15:46:04 769
原创 SCC Tarjan算法
void tarjan( int u, int fa ){ low[u] = dfn[u] = ++time; S.push(u); for( int i = 0; i < map[u].size(); i ++ ) { int v = map[u][i]; if( !dfn[v] ) { tarj
2013-12-05 13:55:14 712
原创 图论连通性历程
Tarjan算法POJ-1144 Network 求割点hdu - 4738 Caocao's Bridges 割边POJ-1523 SPF 割点HDU-3177 Redundant Paths 无向图双连通poj 2942 圆桌武士 双连通分量+二分图+奇圈判断
2013-12-04 18:41:36 838
原创 POJ-1523 SPF 割点
题意:给你幅图,求割点 对每个点去掉后联通分量数;裸Tarjan#include#include#include#includeusing namespace std;const int maxn = 1025;const int inf = 1<<29;int n,son;vectormap[maxn];int dfs_clock,low[maxn],dfn[m
2013-12-04 12:38:03 468
原创 POJ-1904 King's Quest 强连通分量求完美匹配
http://poj.org/problem?id=1904题目意思:有n个女生和n个男生,给定一些关系表示男生喜欢女生(即两个人可以结婚),再给定一个初始匹配,表示这个男生和哪个女生结婚,初始匹配必定是合法的.求每个男生可以和哪几个女生可以结婚其他人还难能都找个女生结婚。思路:第一反应还以为是求二分完美匹配,百度题解再知道用连通分量 0.0 将男生从1到n编号,女生从(n+1)到2
2013-12-03 20:08:10 667
原创 POJ1486 Sorting Slides 二分图最大匹配 必要匹配
http://poj.org/problem?id=1486题意:读题读得很纠结~~大意就是平面坐标上有一系列的矩形(各边都和坐标轴平行)和一些点;每个矩形和在他之内的点对应;然后找出那些绝对匹配(就是在任何最大匹配中,某个矩形和某个点始终对应);所谓必要匹配在本题中的意思就是,在所有的最大匹配中,1个数字都会匹配到同一个字母上去。数字x只能
2013-12-02 10:09:39 585
原创 POJ-2449 Remmarguts' Date k短路
#include#include#include#includeusing namespace std;const int maxn = 1010;const int inf = 1<<29;int n,m;int dis[maxn],outque[maxn],vis[maxn];struct node{ int id,w; node( int a,int b
2013-12-01 14:07:50 452
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人