单调队列,我用deque维护。这道题不难写,我第二次写单调队列,1次AC。-----------------------------------------------------------------------------------#include#include#include#defin...
题意:给定一个长度为n的序列,依次求出(i,i+k-1) (i∈(0,n-1),i
本题有多种解法。首先,暴力的时间复杂度是O((n-k)*klogk),所以pass。
解法1:维护一个单调递增的队列(手写),队头即为最小值。同理求出最大值。
解法2:维护一个优先队列(priority_queue即可)
解法3:线段树
这里给出单调队列解法:
#include
#inc...
#includeusing namespace std;#define N 1000001int n,K,a[N],head=1,tail=1,q[N],ans[N];int main(){ scanf("%d%d",&n,&K); for(int i=1;i=head) --tail; q[...
Problem Description
The 15-puzzle has been around for over 100 years; even if you don't know it by that name, you've seen it. It is constructed with 15 sliding tiles, each with a number from 1 to 15 on it, and all packed into a 4 by 4 frame with one tile m...
分类:
编程语言 时间:
2015-02-15 09:29:04
阅读次数:
1023
Sliding WindowTime Limit: 12000MSMemory Limit: 65536KTotal Submissions: 41264Accepted: 12229Case Time Limit: 5000MSDescriptionAn array of size n ≤ 106...
题意很简单,给出n,m。查询连续m个数的最大值和最小值。
我用线段树 裸的。有人用的单调队列。
不过很忧伤的是G++ TLE,但是C++ AC了。
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#includ...
转载请注明出处:
我们平时看到的菜单,都有侧滑菜单,有的只有右侧侧滑菜单,有的只有右侧侧滑菜单,有的左侧和右侧都有侧滑菜单。
下面介绍一个有三种模式的侧滑菜单,只有左侧,只有右侧,左侧和右侧都有。
首先要导入一个包,源码Demo中可以下载,然后引入项目中。
baseMenu = new SlidingMenu(this);
baseMenu.setTouchModeAbove(Sli...
分类:
其他好文 时间:
2015-01-22 18:14:15
阅读次数:
158
Question:AlongarrayA[]isgiventoyou.Thereisaslidingwindowofsizewwhichismovingfromtheveryleftofthearraytotheveryright.Youcanonlyseethewnumbersinthewindow.Eachtimetheslidingwindowmovesrightwardsbyoneposition.Followingisanexample:Thearrayis[13-1-35367],andwis3...
A long array A[] is given to you. There is a sliding window of size w which is moving from the very left of the array to the very right. You can only ...
http://www.androiduipatterns.com/2012/06/emerging-ui-pattern-side-navigation.htmlhttps://github.com/mattlogan/CircleMenu/tree/master/samplehttps://git...
分类:
其他好文 时间:
2015-01-10 23:40:58
阅读次数:
225