转自http://biandroid.iteye.com/blog/1399462第一部分 Matrix的数学原理在Android中,如果你用Matrix进行过图像处理,那么一定知道Matrix这个类。Android中的Matrix是一个3 x 3的矩阵,其内容如下:Matrix的对图像的处理可分为...
分类:
移动开发 时间:
2014-07-27 21:48:49
阅读次数:
384
一个N*N(1
C x1,y1,x2,y2 表示从x1行y1列到x2行y2列的元素全部反转(0变成1,1变成0);
Q x y表示询问x行y列的元素是0还是1。
题目乍一看感觉还是很难,如果能记录每一个元素的状态值,那答案是显而易见的,但是元素过多,如果每次都对每一个元素进行更新状态的话,复杂度太高。实际上只要记录边界的特定坐标的反转次数,最好的选择那就是二维树状数组了。
...
分类:
其他好文 时间:
2014-07-27 11:17:02
阅读次数:
215
Given an integer n, generate a square matrix filled with elements from 1 to n2 in spiral order.For example, Given n = 3,You should return the followin...
分类:
其他好文 时间:
2014-07-27 10:21:02
阅读次数:
219
Given a matrix of m x n elements (m rows, n columns), return all elements of the matrix in spiral order.For example, Given the following matrix:[ [ 1,...
分类:
其他好文 时间:
2014-07-27 10:16:02
阅读次数:
135
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
题目:Given a 2D binary matrix filled with 0's and 1's, find the largest rectangle containing all ones and return its area.题解:这道题可以应用之前解过的Largetst Recta....
分类:
编程语言 时间:
2014-07-26 09:55:57
阅读次数:
301
Given a 2D binary matrix filled with 0's and 1's, find the largest rectangle containing all ones and return its area.题解,很巧妙的一道题,对于一个0-1矩阵,它的每一行及以上都可以看...
分类:
其他好文 时间:
2014-07-25 10:53:01
阅读次数:
292
累了就要写题解,最近总是被虐到没脾气。
来回最短路问题貌似也可以用DP来搞,不过拿费用流还是很方便的。
可以转化成求满流为2 的最小花费。一般做法为拆点,对于 i 拆为2*i 和 2*i+1,然后连一条流量为1(花费根据题意来定) 的边来控制每个点只能通过一次。
额外添加source和sink来控制满流为2。
代码都雷同,以HDU3376为例。
#include
#include
#...
分类:
其他好文 时间:
2014-07-23 22:40:08
阅读次数:
560
#pragma warning(disable:4996)
#include <cstdio>
#include <Windows.h>
#include <tchar.h>
#include <vector>
using namespace std;
/*
submit time : 2
1. Runtime Error
[]
request :
Given a ma...
分类:
其他好文 时间:
2014-07-23 21:34:35
阅读次数:
274