原题http://acm.timus.ru/problem.aspx?space=1&num=1804
D - The Machinegunners in a Playoff
Time Limit:500MS Memory Limit:65536KB 64bit IO Format:%I64d
& %I64u
Submit Status
Desc...
分类:
其他好文 时间:
2014-07-28 00:29:30
阅读次数:
242
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
用优先队列实现
模板:
struct node
{
int pos, dist;
friend bool operator b.dist;
}
};
int Dijkstra(int n,int start,int end)
{
bool visited[maxn]...
分类:
其他好文 时间:
2014-07-28 00:07:00
阅读次数:
305
解题思路:
题目唯一难点就是如何去表示地点,用map映射可以轻松搞定,一个地点名对应一个值,剩下的就是求最短路径。下面给出三个代码,第一个是用朴素Dijkstra写的,第二个用了Floyd,第三个用了Dijkstra + heap。感觉上运行效率差不多。。。。。
AC代码:
Dijkstra:
#include
#include
#include
#include
usin...
分类:
其他好文 时间:
2014-07-28 00:05:29
阅读次数:
349
heap block 引发的思考
问题背景:
Implicit Free Lists
Any practical allocator needs some data structure that allows it to distinguish block boundaries and to distinguish between allo...
分类:
其他好文 时间:
2014-07-27 23:38:29
阅读次数:
452
/*** 栈(Stack) :存放基本类型的变量数据和对象的引用,但对象本身不存放在栈中,而是存放在堆(new 出来的对象)或者常量池中(字符串常量对象存放 在常量池中)。 堆(heap):存放所有new出来的对象。* 静态存储:存放静态成员(static定义的)。 常量池(...
分类:
编程语言 时间:
2014-07-27 22:45:19
阅读次数:
320
Deferred lighting separate lighting rendering and make lighting a completely image-space technique. This is very different the forward rendering. At f...
分类:
其他好文 时间:
2014-07-27 21:43:45
阅读次数:
1430
题目:Given a sorted array, remove the duplicates in place such that each element appear only once and return the new length.Do not allocate extra space....
分类:
编程语言 时间:
2014-07-27 21:26:35
阅读次数:
267
Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in place.click to show follow up.Follow up:Did you use extra space...
分类:
其他好文 时间:
2014-07-26 14:29:30
阅读次数:
183
题目:Sort a linked list in O(n log n) time using constant space complexity.题解:考虑到要求用O(nlogn)的时间复杂度和constant space complexity来sort list,自然而然想到了merge sor....
分类:
编程语言 时间:
2014-07-26 09:51:57
阅读次数:
307