![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
技巧--尺取法
exmy
Less is more, and more is less.
展开
-
codeforces--701C They Are Everywhere(尺取法)
[cf 701Chttp://codeforces.com/problemset/problem/701/C)题解求包含所有出现过的元素的最短区间长度。见 poj–3320 Jessica’s Reading Problem(尺取法) ](http://blog.csdn.net/xushao_movens/article/details/51051111)#include <bits/stdc+原创 2016-07-24 21:30:21 · 580 阅读 · 0 评论 -
UVa--11572 Unique Snowflakes(尺取法)
UVa 11572题意在序列中找到一个尽量长的连续子序列,使得该序列中没有相同的元素。题解尺取法。 设连续子序列为 S[L..R]S[L..R], 初始 L=R=0L = R= 0,R不断增加直到序列中会出现重复元素,这时子序列无法再向右延伸了,那么增加L,然后继续延伸R.判断是否可以延伸可以用set。 总的时间复杂度:O(nlogn)O(nlogn)#include <bits/stdc++.原创 2016-04-26 22:59:04 · 494 阅读 · 0 评论 -
poj--3320 Jessica's Reading Problem(尺取法)
poj 3320题意给定长度为n的区间,求其长度最短并且包含区间所有出现过的元素的子区间。题解假设区间[s,t][s, t]覆盖了所有元素,那么区间[s+1,t′][s+1, t^{'}](t′>=t)(t^{'}>=t),也要覆盖所有的元素。#include <iostream> #include <cstring> #include <cstdio> #include <algorithm> #原创 2016-04-03 17:27:10 · 440 阅读 · 0 评论 -
poj--3061 Subsequence(前缀和 or 尺取法)
poj 3061题意求长度为n的序列的一个长度最小而其和不小于S的子序列。题解先计算每个位置前缀和,枚举子序列的起点,二分搜索使序列和不小于S的末尾位置。#include <iostream> #include <cstring> #include <algorithm> using namespace std;typedef long long ll; const int maxn = 10000原创 2016-04-03 14:25:12 · 569 阅读 · 0 评论