The modern meaning for algorithm is quite similar to that of recipe, process, method, technique, procedure, routine, rigmarole, except that the word "...
分类:
其他好文 时间:
2014-07-16 19:15:58
阅读次数:
184
思路:莫队算法,离线操作,将所有询问的左端点进行分块(分成sqrt(n) 块每块sqrt(n)个),用左端点的块号进行排序小的在前,块号相等的,右端点小的在前面。 这样要是两个相邻的查询在同一块内左端点每次最多移动sqrt(n) n次的话效率为nsqrt(n) ,对于同一块内右端点为有序的那么最多移...
分类:
其他好文 时间:
2014-07-16 18:16:59
阅读次数:
218
题目:hdoj1045
题意:给出一个图,其中有 . 和 X 两种,. 为通路,X表示墙,在其中放炸弹,然后炸弹不能穿过墙,问你最多在图中可以放多少个炸弹?
分析:这道题目是在上海邀请赛的题目的数据简化版,数据水了,所以有很多方法,这里讲二分图最大匹配,题目难点在于建图
想到用暴力过,但是事实证明我想多了。然后又想到多重二分匹配,后来发现没有办法表示图中的行列中墙的阻隔,后来...
分类:
其他好文 时间:
2014-07-16 17:21:27
阅读次数:
196
思路是这样的,我们从第一个字符开始向后依次找,直到找到一个断句的地方,使得当前获得的子串在dict中,若找到最后都没找到,那么就是False了。
在找到第一个后,接下来找下一个断句处,当然是从第一个断句处的下一个字符开始找连续的子串,但是这时与第一个就稍有不同,比如说word=‘ab’, dict={ 'a', ab', ...},在找到a后,接下来处理的是b,我们发现b不在dict中,但是我们...
分类:
编程语言 时间:
2014-07-16 17:09:39
阅读次数:
273
先写下这个问题的模式
def preorderTraversal(self, root):
if root == None: return []
re = []
insert root to stack s
while s not empty:
cur_root = top of stack s
s.pop()
how to handle cur_root
how to ...
分类:
其他好文 时间:
2014-07-15 10:17:43
阅读次数:
274
● BASE64 严格地说,属于编码格式,而非加密算法 ● MD5(Message Digest algorithm 5,信息摘要算法) ● SHA(Secure Hash Algorithm,安全散列算法) ● HMAC(Hash Message Authentication Code,散列消息....
分类:
编程语言 时间:
2014-07-14 23:03:29
阅读次数:
476
#@ root: the root of searched tree
#@ nodeToFind: the tree-node to be found
#@ path: the path from root to node
#@@
#@@ search tree referenced by root, and return the path
#@@ from root to node, if n...
分类:
其他好文 时间:
2014-07-14 16:45:51
阅读次数:
217
上一篇 说了些堆的建立及其相关操作,这里看下用堆来解决数据量较大的时候,查找最小的k个数的情况。这里会用到上一篇中的函数。
我们先生存1千万个随机数,写到文件中:
import random
def randData():
with open('randint.txt', 'w') as fd:
for i in range(1, 10000000):
fd.write('%...
分类:
其他好文 时间:
2014-07-13 18:51:05
阅读次数:
261
Time Limit:1000MS Memory Limit:65536KB 64bit IO Format:%I64d
& %I64u
Submit Status
Description
A checksum is an algorithm that scans a packet of data and returns a single numb...
分类:
其他好文 时间:
2014-07-13 18:47:10
阅读次数:
219
题目链接:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=2136
Problem A
Another n-Queen Problem
I guess the n-queen problem is known by every ...
分类:
其他好文 时间:
2014-07-13 18:16:11
阅读次数:
498