2014年百度之星程序设计大赛 - 初赛(第二轮)
树状数组貌似是考察点。我目前只会模拟,闲了再说。...
分类:
其他好文 时间:
2014-06-05 08:46:59
阅读次数:
201
【题目】
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
【题目大意】有一个数列P,它的第i项是当x=i时,一个关于x的整式的值。给出数列的前S项,你需要输出它的第S+1项到第S+C项,并且使整式的次数最低。多测。【数据范围】数据组数≤5000,S+C≤100思路:使用差分的方法进行解题,然后再逆向回去实例:
原数列1,2,4,7,11,16,22,29....
分类:
其他好文 时间:
2014-06-03 06:38:41
阅读次数:
290
BNUOJ 34981 A Matrix
题目地址:BNUOJ 34981
题意:
给你一个把一个排列放到矩阵里面的算法和矩阵,要你从矩阵写出排列。
如果答案有多个,输出翻转后字典序最大的那个。
分析:
想了半天只能想到链表版的,而且很可能TLE,看了帆神的题解后豁然开朗..Orz..
代码:
/*
* Author: illuz
*...
分类:
其他好文 时间:
2014-06-03 02:15:20
阅读次数:
187
匈牙利算法。 1 #include 2 #include 3 4 #define MAXNUM
1005 5 6 char map[MAXNUM][MAXNUM]; 7 char visit[MAXNUM]; 8 int son[MAXNUM]; 9 10
int find(int x, i...
分类:
其他好文 时间:
2014-05-31 16:54:26
阅读次数:
291
线段树。 1 #include 2 #include 3 #include 4 using
namespace std; 5 6 #define mymax(a, b) (a>b) ? a:b 7 8 const int maxn =
200005; 9 10 int nums[maxn>...
分类:
其他好文 时间:
2014-05-31 15:22:14
阅读次数:
264
逆序数的性质。1. 暴力解 1 #include 2 3 #define MAXNUM 5005 4
5 int a[MAXNUM]; 6 7 int main() { 8 int n; 9 int i, j, sum, min;10 11 while
(scanf(...
分类:
其他好文 时间:
2014-05-31 07:50:50
阅读次数:
170
Floyd。注意字典序!!! 1 #include 2 #include 3 4
#define MAXNUM 55 5 #define INF 0x1fffffff 6 7 int cost[MAXNUM][MAXNUM]; 8 int
path[MAXNUM][MAXNUM]; 9 in...
分类:
其他好文 时间:
2014-05-31 04:41:38
阅读次数:
218