【题目】
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 of each row is greater than the last integer of the previous ...
分类:
其他好文 时间:
2014-06-05 08:28:43
阅读次数:
321
【题目】
Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in place.
【题意】
给定一个mXn的矩阵,如果其中的元素为0,则对应的行和列都用0填充。
不能申请额外的空间。
【思路】
第一行和第一列空出来标记需要置0的列和行
第一遍扫描:
扫描第一行,判断第一行是否需要清零
...
分类:
其他好文 时间:
2014-06-05 08:07:11
阅读次数:
229
题目来源:POJ 2155 Matrix
题意:开始矩阵都是0 2种操作 把某个子矩阵翻转 0变1 1变0 查询x y 是0还是1
思路:树状数组 记录翻转次数就行 奇数次是1 偶数次是0
这题是区间更新 点查询 向上求和 向下更新 而且是二维的
#include
#include
using namespace std;
const int maxn = 1300;
i...
分类:
其他好文 时间:
2014-06-05 01:59:00
阅读次数:
287
POJ 1150 The Last Non-zero Digit 数论+容斥
题目地址:
POJ 1150
题意:
求排列P(n, m)后面第一个非0的数。
分析:
为了熟悉题目中的理论,我先做了俩初级的题目:
POJ 1401,题解见:POJ
1401 && ZOJ 2202 Factorial 阶乘N!的末尾零的个数
NYOJ 954,题解见:NYO...
分类:
其他好文 时间:
2014-06-04 22:49:42
阅读次数:
322
You are given annxn2D matrix representing an
image.Rotate the image by 90 degrees (clockwise).Follow up:Could you do this
in-place?classSolution{publi...
分类:
其他好文 时间:
2014-06-04 20:25:09
阅读次数:
227
Given a matrix ofmxnelements (mrows,ncolumns),
return all elements of the matrix in spiral order.For example,Given the
following matrix:[ [ 1, 2, 3 ]....
分类:
其他好文 时间:
2014-06-04 20:06:52
阅读次数:
256
Given an integern, generate a square matrix
filled with elements from 1 ton2in spiral order.For example,Givenn=3,You should
return the following matri...
分类:
其他好文 时间:
2014-06-04 19:28:23
阅读次数:
220
BNUOJ 34981 A Matrix
题目地址:BNUOJ 34981
题意:
给你一个把一个排列放到矩阵里面的算法和矩阵,要你从矩阵写出排列。
如果答案有多个,输出翻转后字典序最大的那个。
分析:
想了半天只能想到链表版的,而且很可能TLE,看了帆神的题解后豁然开朗..Orz..
代码:
/*
* Author: illuz
*...
分类:
其他好文 时间:
2014-06-03 02:15:20
阅读次数:
187
1 2 13 25 26 You can count on this being a dark
29 background with light text on top, but should try to make no 30 other
assumptions ...
分类:
移动开发 时间:
2014-05-31 06:12:59
阅读次数:
492
Rotate ImageYou are given an n x n 2D matrix
representing an image.Rotate the image by 90 degrees (clockwise).Follow up:
Could you do this in-place?最简...
分类:
其他好文 时间:
2014-05-29 23:02:38
阅读次数:
254