码迷,mamicode.com
首页 >  
搜索关键字:algorithm    ( 11758个结果)
POJ 2485(Kruskal算法)
第一道Kruskal算法题#include #include #include using namespace std;#define max 505int f[max],maxw;struct edge{ int st,en,w;}ed[max*max/2];int find(int k){ if...
分类:其他好文   时间:2014-07-28 15:39:43    阅读次数:181
LeetCode——Swap Nodes in Pairs
Given a linked list, swap every two adjacent nodes and return its head. For example, Given 1->2->3->4, you should return the list as 2->1->4->3. Your algorithm should use only constant space. Y...
分类:其他好文   时间:2014-07-28 00:28:19    阅读次数:273
POJ 1273 Drainage Ditches (网络最大流)
http://poj.org/problem?id=1273 Drainage Ditches Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 55235   Accepted: 21104 Description Every time i...
分类:其他好文   时间:2014-07-28 00:24:09    阅读次数:220
UVA 10594 Data Flow (最小费用流)
http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=116&page=show_problem&problem=1535  Problem F Data Flow Time Limit 5 Seconds   I...
分类:其他好文   时间:2014-07-28 00:17:39    阅读次数:381
POJ 2828 Buy Tickets (线段树)
题目大意: 排队有人插队,每一次都插到第 i 个人的后面。 最后输出顺序。 思路分析: 你会发现,如果反向处理的话,你就知道这个人是第几个了。 那么问题一下子就简化了。 就是在线段树上找第几个空位置就行了。 #include #include #include #include #include #define lson num<<1,s,mid #defi...
分类:其他好文   时间:2014-07-28 00:14:39    阅读次数:229
Visualize Surface by Delaunay Triangulator
Abstract. Delaunay Triangulation is the core algorithm for mesh generation. By Delaunay Triangulator you can make a general method to visualize geomet...
分类:其他好文   时间:2014-07-27 23:18:49    阅读次数:594
UVA 10608
并查集的水题,比赛时怎么都AC不了,后来发现是没有考虑先3 2 后1 2的情况,下次注意!#include#include#includeusing namespace std;int x[30010];int k[30010];int num[30010];int find(int y){ ...
分类:其他好文   时间:2014-07-27 22:18:59    阅读次数:228
poj 1655 Balancing Act 【树的重心】
知识点:树的重心 定义:以这个点为根,那么所有的子树(不算整个树自身)的大小都不超过整个树大小的一半。 性质: 性质 1 :树中所有点到某个点的距离和中,到重心的距离和是最小的,如果有两个距离和,他们的距离和一样。 性质 2 :把两棵树通过某一点相连得到一颗新的树,新的树的重心必然在连接原来两棵树重心的路径上。 性质 3 :一棵树添加或者删除一个节点,树的重心最多只移动一...
分类:其他好文   时间:2014-07-27 11:44:53    阅读次数:238
poj Yogurt factory (贪心水题)
# include # include # include using namespace std; int main() { int i,n,s; __int64 sum ; int cost[10010],num[10010]; while(~scanf("%d%d",&n,&s)) { for(i=0;i<n;i++) scanf("%d%d",&cost[i],&...
分类:其他好文   时间:2014-07-27 11:34:02    阅读次数:144
POJ2155 Matrix 二维树状数组应用
一个N*N(1 C x1,y1,x2,y2 表示从x1行y1列到x2行y2列的元素全部反转(0变成1,1变成0); Q x y表示询问x行y列的元素是0还是1。         题目乍一看感觉还是很难,如果能记录每一个元素的状态值,那答案是显而易见的,但是元素过多,如果每次都对每一个元素进行更新状态的话,复杂度太高。实际上只要记录边界的特定坐标的反转次数,最好的选择那就是二维树状数组了。 ...
分类:其他好文   时间:2014-07-27 11:17:02    阅读次数:215
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!