码迷,mamicode.com
首页 >  
搜索关键字:pair    ( 2800个结果
lua的ipair与pair究竟有什么区别
先看看官方手册的说明吧: pairs (t)If t has a metamethod __pairs, calls it with t as argument and returns the first three results from the call. Otherwise, returns three values: the next function, the table t, a...
分类:其他好文   时间:2014-09-12 01:16:42    阅读次数:304
Dijkstra单源最短路算法的C++实现
这是一个简易的Dijkstra算法的优化实现,利用了堆,这里使用C++中的优先级队列。利用STL内置的堆实现只是优化的第一步,更进一步的优化包括使用Fibonacci堆等更高级数据结构。算法中,使用邻接表作为存储图的数据结构,利用一个int数组d保存过程中及最后得到的最短路长度,再自定义一个pair...
分类:编程语言   时间:2014-09-09 19:58:49    阅读次数:285
c++如何理解map对象的value_type是pair类型
map 是以 pair形式插入的。map中的元素的类型value_typetypedef pair value_type;value_type 被声明为 pair 但并不是简单的 pair 因为用一个非常量的迭代器或引用不能改变关联容器的Key。#include #include int mai.....
分类:编程语言   时间:2014-09-09 11:08:28    阅读次数:158
LeetCode--Binary Tree Maximum Path Sum
递归,dfs这里返回值是一个pair,first表示两个子树的不经过当前root的最大pathsum;second表示两个子树的,以root->left和root->right为路径起始节点的路径的最大值 1 /** 2 * Definition for binary tree 3 * stru.....
分类:其他好文   时间:2014-09-07 19:43:15    阅读次数:195
POJ 3522 Slim Span
Given an undirected weighted graph G , you should find one of spanning trees specified as follows. The graph G is an ordered pair (V, E) , where V is a set of vertices {v1, v2,..., vn} and E is a...
分类:其他好文   时间:2014-09-06 22:36:34    阅读次数:358
python基础 -- acm
浙大acm,第一题 Calculate a + b Input The input will consist of a series of pairs of integers a and b,separated by a space, one pair of integers per line. Output For each pair of input integers a ...
分类:编程语言   时间:2014-09-03 06:16:56    阅读次数:260
CF359D Pair of Numbers [RMQ+ST算法]
题意: 给一串数,找出最长的区间使得这个区间里面有个数能被其他所有数整除(包括它自己),求满足这个条件的最长区间的个数及长度,以及这些区间的左端的位置 分析: 这个区间的要求其实就是GCD(ALL)=MIN(ALL),能被其他数整除,这个数肯定是最小的,然后又能被其他数整除(包括自己)这个数就是GCD了 可以二分枚举区间长度,然后验证答案的可靠性 对当前长度的所有区间,套用RMQ...
分类:其他好文   时间:2014-09-01 14:05:53    阅读次数:248
33. Minimum Depth of Binary Tree && Balanced Binary Tree
思想:先序遍历。注意的是: 当只有一个孩子结点时,深度是此孩子结点深度加 1 . 思想: 先序遍历。既要返回左右子树判断的结果,又要返回左右子树的深度进行再判断。 所以要么返回一个 pair, 要么函数参数增加一个引用来传递返回值。
分类:其他好文   时间:2014-08-27 18:25:08    阅读次数:207
zoj 1456 Minimum Transport Cost (Floyd+路径记录)
Minimum Transport Cost Time Limit: 2 Seconds      Memory Limit: 65536 KB These are N cities in Spring country. Between each pair of cities there may be one transportation track or none. Now ther...
分类:其他好文   时间:2014-08-27 13:07:27    阅读次数:235
14D-树形DP
找出树中2条不重复的路径使其路径长度乘积最大#include #include #include #include #include using namespace std;const int MAXN = 205;typedef pair Edge;vector adj[MAXN];bool de...
分类:其他好文   时间:2014-08-26 13:32:16    阅读次数:197
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!