- 博客(6)
- 资源 (4)
- 收藏
- 关注
原创 poj 2607 Fire Station
枚举点求单源最短路Memory: 748K Time: 204MSLanguage: G++ Result: Accepted #include#include#include#include#include#includeusing namespace std;const int maxn=505;const
2012-04-29 11:45:11 444
原创 hdu 3902 Swordsman 判断多边形对称
//很久没写过计算几何了,想在东北邀请赛前热热手,找了这道比较水的题,结果还是纠结了一会。//一开始想当然的以为对称轴必过多边形重心,于是引入了重心优化,结果WA了N次,最后去掉这个,就过了。。。//加上每条边的中点,一共2*n个点。枚举n条可能的对称轴(p[i], p[i+n]),i从0到n-1。#include#include#include#include#include
2012-04-19 10:31:20 559
原创 poj 3687 Labeling Balls 拓扑排序
//很巧妙的反向建图,先放最重的编号最大的可使字典序最小,用优先队列实现,贪心思想。//拓扑排序需要特别注意重边!#include#include#include#includeusing namespace std;int n, m, cnt[205], a[205][205], seq[205];bool topo_sort(){ int i, j, t;
2012-04-11 15:23:55 338
原创 poj 1094 Sorting It All Out 拓扑排序
拓扑排序方法: (1)从有向图中选择一个没有前驱(即入度为0)的顶点并且输出它. (2)从网中删去该顶点,并且删去从该顶点发出的全部有向边. (3)重复上述两步,直到剩余的网中不再存在没有前趋的顶点为止. #include#include#include#includeint n, m, a[30][30], count[30], top, seq[30], c[
2012-04-10 22:32:10 285
原创 hdu 1024 Max Sum Plus Plus 最大m子段和
由于数据很大,利用滚动数组。状态转移方程 dp[1][j]=max(dp[0][j-1]+a[j], dp[1][j-1]+a[j]);dp[0][j-1]表示a[1]到a[j-1]的i-1个子段的最大值,不一定包含a[j-1]。dp[1][j-1]表示a[1]到a[j-1]的i个子段的最大值,一定包含a[j-1]。dp[1][i]表示a[1]到a[j]的i个子段的最大值,一定包含
2012-04-08 22:09:40 440
原创 poj 1364 King 差分约束
//注意差分约束只能求>=或//对于差分不等式,a - b = c ,建一条 b 到 a 的权值为 c 的边,求的是最长路,得到的是最小值。存在负环的话是无解,求不出最短路(dist[ ]没有得到更新)的话是任意解。//建图中有时候会用到一个虚点,这个点到图中每个实点的距离(dist[ ])为0,当然这个点的作用是方便图中的点入队(spfa算法),然后使这些实点的dist[ ]值得到更新。
2012-04-04 21:40:06 299
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人