码迷,mamicode.com
首页 >  
搜索关键字:veth pair    ( 2862个结果
Project Euler :Problem 54 Poker hands
In the card game poker, a hand consists of five cards and are ranked, from lowest to highest, in the following way: High Card: Highest value card.One Pair: Two cards of the same value.Two Pairs: Tw...
分类:其他好文   时间:2015-07-07 17:09:16    阅读次数:131
C++中vector的排序问题
在用vector排序的时候,发现sort()函数有一个问题,sort排序只会返回排序后的结果,不会返回每个排序后的结果在原来的编号。//template bool cmp(const pair &x,const pair &y) { return x.second > y.second; } //template void sortVector(vector &value, vector...
分类:编程语言   时间:2015-07-06 21:48:37    阅读次数:133
Google interview question: disjoint-set questions
Question:Given a n,m which means the row and column of the 2D matrix and an array of pair A( size k). Originally, the 2D matrix is all 0 which means t...
分类:其他好文   时间:2015-07-02 06:36:01    阅读次数:162
[CF310]D. Case of Fugitive
题意: 给出n个线段,在n个线段之间搭桥,给出m个桥的长度,假如满足条件 To reach the goal, Andrewid needs to place a bridge between each pair of adjacent islands. A bridge of length a can be placed between the i-th and the (i?+?1)-th...
分类:其他好文   时间:2015-06-30 14:59:41    阅读次数:141
跟连乐一起学Scala-类型参数
欢迎加入Scala讨论QQ群212859367,和连乐一起讨论学习!泛型类例子:class Pair[T, S](val first: T, val second: S)泛型函数例子:def getMiddle[T](a: Array[T] = a(a.length / 2))Scala会从调用该方法使用的实际参数来推断出类型。getMiddle(Array("Mary", "had", "a",...
分类:其他好文   时间:2015-06-27 09:50:59    阅读次数:105
Axis­ Aligned ?Rectangles
Describe an algorithm that takes an unsorted array of axis‐aligned rectangles and returns any pair of rectangles that overlaps, if ...
分类:其他好文   时间:2015-06-26 23:37:54    阅读次数:202
js获取url 参数
window.getRequest = function (url) { var theRequest = new Array(); if (url.indexOf("?") > -1) { var pair = url.substr(1).spl...
分类:Web程序   时间:2015-06-25 11:52:33    阅读次数:126
UVa - 1153 - Keep the Customer Satisfied
用pair作为基本结构保存q和d,在用一个数组vector<pair >来存储输入数据。然后按照等待时间 d 排序,注意用sort排序默认是用first,这里的的first是q,所以要重写一个比较函数,用second排序。 接下来就是贪心算法,用优先队列priority_queue<pair > 存储结果,这里体现了用pair的优点,刚好优先队列中就是first高优先级高。 一个个入队,如果总时间超过了当前限制时间,则把队中花费时间最长的元素(就是q最大的)删掉。...
分类:其他好文   时间:2015-06-25 09:03:00    阅读次数:205
Uva - 1614 - Hell on the Markets
先考虑一个问题,总和为零,那么意味着正数之和与负数之和的绝对值相等,那么所有数的绝对值之和必定是偶数,所以先判断绝对值之和是不是偶数,不是偶数直接无解。 如果是偶数,把绝对值之和除以2就是正数之和,把输入的序列排序,然后从大到小贪心求解。因为排序之后顺序有了变化,所以用了pair存储,first是值,而second是原始序列中的位置,这样排序的时候存储位置的值也是跟着变化,但每个值的原始位置信息还保存完好。...
分类:其他好文   时间:2015-06-24 22:40:57    阅读次数:158
Maximum Gap
这里要用到桶排序,感觉不太感兴趣,就直接看了网上的做法。C++中vector中的一些常用函数:取容器中的最大最小值min_element(),max_element()。当有必要对一个接受pair参数的函数传递两个值时, make_pair()尤其显得方便。int minAll = *min_ele...
分类:其他好文   时间:2015-06-23 19:57:47    阅读次数:124
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!