1 a = range(3)2 b = range(3)3 [ (x, y) for x, y in zip(a, b) ]结果:1 [ (0,0), (1,1), (2,2) ]当然,如上可以推广到多个列表。
分类:
编程语言 时间:
2015-02-21 18:49:27
阅读次数:
756
简单的RMQ,可我怎么写都WA。不明白,找了一个和我相似的贴过了,要赶着去外婆家。#include #include #include #include #include #include #include #include #include #include #include #define ep...
分类:
其他好文 时间:
2015-02-20 10:51:40
阅读次数:
170
题意:
有n*m的矩阵,然后你有k发子弹。现在你可以朝着任意列发射子弹,每一发子弹都会使该列上的数值-1,最小减少到0。
现在问你连续最长的行数,在k发子弹内,使得这些行上的数值全部为0.
思路:
简单的二分枚举最长行数区间,每个区间的最大值决定了要发射的子弹数,所以是RMQ问题,当然这里的枚举全部枚举,用尺取法也可以。
//889 ms
#include
#incl...
分类:
其他好文 时间:
2015-02-19 16:19:13
阅读次数:
130
一、 题目
给出一个已经排好序的数组和一个数字,找出在这个数字在数组中的范围。
例如:[5,7,7,8,8,10]和8
返回:[3,4]
二、 分析
题目很基础,就是找出等值的数字的开始和结束索引,上去就遍历当第一次遇到等值时记录下左索引,最后一次遇到记录下右索引也不会超时。如下:
//遍历法
class Solution {
public:
vector searchRang...
分类:
其他好文 时间:
2015-02-16 14:22:22
阅读次数:
186
Some math I did ... (not 100% verified, but looks like it works)
n = near
f = far
z = depth buffer Z-value
EZ = eye Z value
LZ = depth buffer Z-value remapped to a linear [0..1] range (near plane t...
分类:
其他好文 时间:
2015-02-16 11:47:34
阅读次数:
195
for 循环Swift 提供两种 for 循环形式:(1)for-in 用来遍历一个区间(range),序列(sequence),集合(collection),系列(progression)里面所有的元素执行一系列语句。(2)for 条件递增语句。用来重复一系列语句。for-in可以使用 for-i...
分类:
编程语言 时间:
2015-02-15 20:36:27
阅读次数:
284
Problem
An army of n droids is lined up in one row. Each droid is described by m integers a1,?a2,?...,?am, where ai is the number of details of the i-th type in this droid’s m...
分类:
其他好文 时间:
2015-02-15 13:33:42
阅读次数:
155
# -*-coding:UTF-8-*-# Filename:001.py# 题目:有1,2,3,4个数字,能组成多少个互不相同且无重复数字的三位数?输出结果cnt = 0 # count the sum of resultfor i in range(1, 5): for j in ran...
分类:
编程语言 时间:
2015-02-13 22:26:43
阅读次数:
303
在一个字符串A中搜索特定字符串BNSInteger locationBegin = 0;//开始搜索字符串A do { NSRange range = [A rangeOfString:B options:NSCaseInsensitiveSe...
分类:
其他好文 时间:
2015-02-13 14:47:33
阅读次数:
110
参考:点击打开链接 点击打开链接 点击打开链接(一些总结) 点击打开链接(不错的模板)
题目:点击打开链接
花了4天时间做完了这个专题,LCA的问题用处还是很大,同时能体会RMQ的ST算法中dp的味道.基本方法就是ST,LCA转RMQ,LCA的Tarjan,LCA倍增(这个可存储边权)
这个专题后面四道题都非常好,推荐大家做做.
细节:
1. ST方法2^i 包含自己,因此其真...
分类:
其他好文 时间:
2015-02-13 10:11:09
阅读次数:
167