【题目】
原文:
1.7 Write an algorithm such that if an element in an MxN matrix is 0, its entire row and column is set to 0.
译文:
写一个函数处理一个MxN的矩阵,如果矩阵中某个元素为0,那么把它所在的行和列都置为0.
【分析】
【思路一】
遍历一次矩阵...
分类:
其他好文 时间:
2014-05-15 12:27:37
阅读次数:
293
题目链接:http://poj.org/problem?id=2135
Farm Tour
Time Limit: 1000MS
Memory Limit: 65536K
Total Submissions: 10862
Accepted: 4024
Description
When FJ's f...
分类:
其他好文 时间:
2014-05-15 11:24:14
阅读次数:
348
题目链接:点击打开链接
二叉树的应用,一开始自己真的没有思路,参考了http://blog.csdn.net/yangliuy/article/details/7250997
自己一开始真的TLE,还真的是,关键照着作者又降到了0ms,厉害!
最近荒废了很多时间,不,忙活别的事情了,不要忧虑未来,不要忧虑自己参加acm有没有结果,因为,这对于结果毫无影响,在忧虑与悔恨的相关联的感情中,是...
分类:
其他好文 时间:
2014-05-15 08:10:15
阅读次数:
272
题目链接:http://poj.org/problem?id=3469
Dual Core CPU
Time Limit: 15000MS
Memory Limit: 131072K
Total Submissions: 18147
Accepted: 7833
Case Time Limit: 5000MS
...
分类:
其他好文 时间:
2014-05-15 06:23:05
阅读次数:
271
题意:输出一个元素在一个已排序的数组中的位置,如果不存在输出它应该插入的位置
思路:二分查找,如果找到就输出位置,找不到就输出它应该插入的位置
复杂度:时间O(log n),空间O(1)
相关题目:
Search for a Range
Search a 2D Matrix...
分类:
其他好文 时间:
2014-05-15 05:57:32
阅读次数:
271
给你两个四位的素数s和t,要求每次改变一个数字,使得改变后的数字也为素数,求s变化到t的最少变化次数。...
分类:
其他好文 时间:
2014-05-15 05:38:25
阅读次数:
234
题目
Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties:
Integers in each row are sorted from left to right.The first integer...
分类:
其他好文 时间:
2014-05-15 03:41:11
阅读次数:
257
大意:小明喜欢带他的朋友们逛自己的农场。农场有n块地,屋舍位于1号,谷仓位于n号。有m条路连接这些地,路是无向的,每条路长度已知。他想设计一条线路,从1出发,到n,再回到1,且同一条路不走两遍。问最短的行程是多少。
分析:可建模为最小费用最大流。从1出发,到n,再回到1,相当于找到两条从1到n的路径且二者不能有交集。
对于每条路,费用为长度,容量为1,这样就限制了只能走一次。新建一个顶点连向1,费用为0,容量为2.,作为等价源点。同理再建一个等价汇点。
因为重边的存在,图的存储结构为邻接表而非邻接矩阵...
分类:
其他好文 时间:
2014-05-15 01:40:24
阅读次数:
366
Problem Description
Consider the following exercise, found in a generic linear algebra textbook.
Let A be an n × n matrix. Prove that the following statements are equivalent:
1. A is invertible...
分类:
其他好文 时间:
2014-05-15 01:30:21
阅读次数:
309
Description
Businesses like to have memorable telephone numbers. One way to make a telephone number memorable is to have it spell a memorable word or phrase. For example, you can call the Universit...
分类:
其他好文 时间:
2014-05-15 00:20:39
阅读次数:
332