自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(37)
  • 收藏
  • 关注

转载 计算几何题目总结

打算转下来好好做计算几何了。原文地址:http://blog.sina.com.cn/s/blog_49c5866c0100f3om.html  其实也谈不上推荐,只是自己做过的题目而已,甚至有的题目尚未AC,让在挣扎中。之所以推荐计算几何题,是因为,本人感觉ACM各种算法中计算几何算是比较实际的算法,在很多领域有着重要的用途计算几何题的特点与做题要领:1.

2015-03-23 17:53:44 550

原创 HDU 1274 The Perfect Stall(二分图匹配)

模版题,wa了一次因为忘记每次都初始化vis数组了。#include #include #include #include #include #define LL long long#define FOR(i, x, y) for(int i=x;i<=y;i++)using namespace std;const int MAXN = 200 + 10;int G[

2015-03-31 17:13:36 415

原创 HDU 3020 Antenna Placement(二分图匹配)

解题思路:相邻的城市连边。#include #include #include #include #include #include #include #include #include #define LL long long#define FOR(i, x, y) for(int i=x;i<=y;i++)using namespace std;const in

2015-03-31 11:51:51 671

原创 HDU 4185 Oil Skimming(离散化 + 二分图匹配)

#include #include #include #include #include #include #include #include #include #define LL long long#define FOR(i, x, y) for(int i=x;i<=y;i++)using namespace std;const int MAXN = 600 + 10

2015-03-30 16:10:48 649

原创 HDU 2819 swap(二分图匹配并记录路径)

#include #include #include #include #include #include #define LL long longusing namespace std;const int MAXN = 100 + 10;int G[MAXN][MAXN];int vis[MAXN];int match[MAXN];int N;int path(int

2015-03-30 11:36:16 424

原创 HDU 1281 棋盘游戏(二分图匹配)

解题思路:枚举棋盘上所有格子,如果讲该点删除后,最大匹配数会减少,则该点为关键点。#include #include #include #include #include #include using namespace std;const int MAXN = 100 + 10;int G[MAXN][MAXN];int vis[MAXN];int match[MAX

2015-03-30 10:12:20 567

原创 HDU 1083 Coures(二分图匹配)

解题思路:裸的匈牙利算法,看最大匹配是否等于P;#include #include #include #include #include #include using namespace std;const int MAXN = 500;int p, n;int G[MAXN][MAXN];int match[MAXN];int vis[MAXN];int path

2015-03-30 09:50:54 551

原创 HDU 2444 The Accomodation of Students(dfs + 匈牙利算法)

题目大意:        有n个学生,有m对人是认识的,每一对认识的人能分到一间房,问能否把n个学生分成两部分,每部分内的学生互不认识,而两部分之间的学生认识。如果可以分成两部分,就算出房间最多需要多少间,否则就输出No。解题思路:先是要判断是否为二部图,然后求最大匹配。 #include #include #include #include #include

2015-03-29 16:39:20 591

原创 POJ 1222 高斯消元

解题思路:30个格子,对每一个格子建立一个方程,高斯消元#include #include #include #include #include #include #include #include #include #include #define LL lonA lonA#define FOR(i, x, y) for(int i=x;i<=y;i++)usin

2015-03-29 16:04:03 576

原创 UVALA 3263 That Nice Euler Circuits(欧拉定理,判断线段相交)

解题思路:欧拉定理: 设平面图的顶点数,边数和面数分别为V,E, F则 V + F - E = 2;本题要求平面数,即 F = E + 2 - V;因此只需要求出顶点数和边数。顶点数除了输入的顶点还包括两条线段相交的交点,同样如果三点共线,则原来的一条边变成了两条边。#include #include #include #include #include #include

2015-03-27 13:55:20 707

原创 POJ 2653 Pick-up sticks(计算几何,判断线段相交)

解题思路:暴力循环,如果一个线段后面的所有线段都不和它相交,则这个线段是top的。#include #include #include #include #include #include #include #include #include #include #define LL long longusing namespace std;const int MAX

2015-03-27 13:17:02 445

原创 HDU 4027 Can you answer these queries(线段树)

#include #include #include #include #include #include #include #include #include #include using namespace std;const int MAXN = 100000 + 10;struct Tree{ int l, r; long long sum;}t

2015-03-25 23:27:49 365

原创 HDU 5191 Building Blocks

#include #include #include #include #include #include #include #define LL long longusing namespace std;const int MAXN = 150000 + 10;LL C[MAXN];LL N, W, H;int main(){ while(scanf("%I64

2015-03-24 23:44:28 376

原创 POJ 1654 Area 求多边形的面积

#include #include #include #include #include #include #include #define LL long longusing namespace std;const int MAXN = 1000000 + 10;int dir[10][2]={{0,0},{-1,-1},{0,-1},{1,-1},{-1,0},{0,0},

2015-03-24 16:53:15 507

原创 POJ 1269 Intersecting Lines(简单计算几何,判断直线的关系)

#include #include #include #include #include #include #include #include #include #include #define LL long long using namespace std;struct Point{ double x, y; Point(double x = 0, double

2015-03-23 18:47:11 390

原创 ZOJ 1610

#include #include #include #include #include #include #include #include using namespace std;const int MAXN = 8000 + 10;struct Tree{ int l, r; int val;}tree[MAXN<<2];int color[MAXN

2015-03-23 11:25:54 350

原创 HDU 4276 The Ghost Blows Light(树型DP)

#include #include #include #include #include #include #include #include #include #include #include using namespace std;const int MAXN = 100 + 10;struct Node{ int next; int to; int val

2015-03-19 10:32:45 451

原创 HDU 4714 Tree2cycle(树型DP)

解题思路:将一棵树变成一个环,如果一个结点的分叉数目大于等于2,则将它与父节点断开,并且断开子结点数目sum - 2条边,并再次连接sum-2个儿子形成一条直链然后这条游离链与另一条游离链相连,共需要2*(sum-1)个操作,如果该结点为根结点,则一共需要2 * (sum - 2)种操作。#include #include #include #include #include #

2015-03-19 09:36:31 681

原创 HDU 4705 Y(树型DP)

#include #include #include #include #include #include #include #pragma comment(linker, "/STACK:16777216")#define LL long long using namespace std;const int MAXN = 100000 + 10;int val[MAXN];

2015-03-18 18:38:48 567

原创 POJ 1655 Balancing Act(树型DP)

#include #include #include #include #include #include #include #include #include #include #define LL long long using namespace std;const int MAXN = 20000 + 10;int dp[MAXN], val[MAXN];vec

2015-03-18 16:41:37 498

原创 HDU 1556 Color the the ball(树状数组)

解题思路:应用树状数组的一个小技巧,每次区间加1的时候只需要在左端点加1,右端点加-1,这样询问的时候便可以直接求和。#include #include #include #include #include #include using namespace std;const int MAXN = 100000 + 10;int C[MAXN];int n;int lo

2015-03-16 12:02:11 408

原创 HDU 5187 zh's contest(快速幂 + 快速乘)

题目大意:As one of the most powerful brushes, zhx is required to give his juniors n problems.zhx thinks the ith problem's difficulty is i. He wants to arrange these problems in a beautiful way.z

2015-03-16 11:36:42 625

原创 HDU 4681 String(DP)

题目大意:给出三个字符串A, B, C,求最长的字符串D,使得D是A,B的公共子序列并且C是D的连续子串。解题思路: 预处理出A,B字符串的正向和反向公共子序列。然后枚举字符串C在A,B中出现的位置起点和终点,则ans为起点左边的最长公共子序列加上字符串C的长度加上起点右边的最长公共子序列。#include #include #include #include #inclu

2015-03-15 10:52:17 885

原创 HDU 1074 Doing Homework(状态压缩 + DP)

Problem Description:Ignatius has just come back school from the 30th ACM/ICPC. Now he has a lot of homework to do. Every teacher gives him a deadline of handing in the homework. If Ignatius hands in

2015-03-14 13:17:24 602

原创 POJ 2923 Relocation(状态压缩+ 01背包)

DescriptionEmma and Eric are moving to their new house they bought after returning from their honeymoon. Fortunately, they have a few friends helping them relocate. To move the furniture, they onl

2015-03-13 18:20:37 500

原创 HDU 4283 You are the one(区间DP)

题目大意:  The TV shows such as You Are the One has been very popular. In order to meet the need of boys who are still single, TJUT hold the show itself. The show is hold in the Small hall, so it attrac

2015-03-13 16:45:46 1064

原创 HDU 4301 Divide Chocolate(DP)

解题思路:预处理出所有答案,dp转移放何曾见代码#include #include #include #include #include #include #include #include #include #include #include #define LL long long using namespace std;const int mod = 1e8

2015-03-13 15:53:05 476

原创 POJ 1847 Tram(最短路)

#include #include #include #include #include #include #include #include #define LL long long using namespace std;const int MAXN = 100 + 10;const int INF = 0x3f3f3f3f;int dis[MAXN];int vis

2015-03-11 21:18:28 476

原创 POJ 3660 Cow Contest(floyd传递闭包)

解题思路:使用floyd算法求传递闭包,若该点与其他所有点的关系都能确定,则该点的名次可以确定。#include #include #include #include #include #include #include #include #include #include #define LL long longusing namespace std;const

2015-03-11 20:24:02 609

原创 POJ 3159 Candies(差分约束)

解题思路:老模版超时了,用的bin神用栈实现的SPFA。#include #include #include #include #include #include #include #include #include #include #define LL long longusing namespace std;const int MAXN = 30000 + 1

2015-03-11 20:00:23 339

原创 HDU 2082 找单词(母函数)

#include #include #include #include #include #include #include #include #include #include #define LL long longusing namespace std;const int MAXN = 50 + 10;int c1[MAXN], c2[MAXN];int a[MA

2015-03-11 16:57:08 443

原创 HDU 1085 Holding Bin-Laden Captive!(母函数)

#include #include #include #include using namespace std;const int MAXN = 8000 + 10;int c1[MAXN], c2[MAXN];int a[5], b[5];void solve(){ memset(c1, 0, sizeof(c1)); memset(c2, 0, sizeof(c2));

2015-03-11 16:39:37 378

原创 HDU1576 A/B(求逆元)

对于正整数和,如果有,那么把这个同余方程中的最小正整数解叫做模的逆元。逆元一般用扩展欧几里得算法来求得,如果为素数,那么还可以根据费马小定理得到逆元为。推导过程如下   #include #include #include #include #include #include #include #include #include #include

2015-03-10 21:35:37 581

原创 POJ 1113 wall (凸包)

解题思路: 凸包的周长加上原的周长,最后四舍五入。#include #include #include #include #include #include #include #include #include #include #define LL long long using namespace std;const int MAXN = 1000 + 10;

2015-03-10 20:58:50 527

原创 codeforces #294(Div 2) A、B、C

题目A: A and B and chess#include #include #include #include #include #include #include #include #define LL long long using namespace std;int main(){ char ch; int w = 0, b = 0; for(int i=

2015-03-09 21:54:46 698

原创 Ubuntu 12.04 下安装qt4

在终端中输入: sudo apt-get install libqt4-dev libqt4-dbg libqt4-gui libqt4-sql qt4-dev-tools qt4-doc qt4-designer qt4-qtconfig等待全部安装完毕,然后在在终端中编写一个helloworld的小程序建立hello.cpp#include #include

2015-03-09 20:38:06 714

原创 Codeforces #295(Div 2) A Pangram、B Two Buttons、C DNA Alignment

A#include #include #include #include #include #include #include using namespace std;int A[50];int main(){ int n; string s; cin>>n; cin>>s; memset(A,0,sizeof(A)); for(int i=0;i<n;i++)

2015-03-09 11:08:18 608

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除