Face The Right Way Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 2899   Accepted: 1338 Description Farmer John has arranged his N (1 ≤ N ≤ 5,000) cows in a row and many of them are facing forward, like good cows. Some of them are facin…
We define the distance of two strings A and B with same length n is dis A,B =∑ i=0 n−1 |A i −B n−1−i | disA,B=∑i=0n−1|Ai−Bn−1−i| The difference between the two characters is defined as the difference in ASCII. You should find the maximum length of tw…
Description Jessica's a very lovely girl wooed by lots of boys. Recently she has a problem. The final exam is coming, yet she has spent little time on it. If she wants to pass it, she has to master all ideas included in a very thick text book. The au…
不得不说,这也许会是一道长期在我的博客里作为“HARD”难度存在的题 这道题能很好的考验选手的思考能力,但本蒟蒻最后还是听了省队爷讲了之后才会...(默默面壁) 题目里,说对于每一个点,是用当前选出的M个里面,最长长度减去最短长度作为价值.也就是说:选择长度介于最长与最短之间的边,是对答案没有影响的.(本蒟蒻并没有想到这一点...) 所以由于这一点,我们可以先对于边的长度排序. 那么题目中提到的M,是“选中多余或等于M条边”,从这里就可以看出,我们只需要选定一个头和一个尾就好,由此可以看出,这个…
题目链接:HDU5806 题意:找出有多少个区间中第k大数不小于m. 分析:用尺取法可以搞定,CF以前有一道类似的题目. #include<cstdio> using namespace std; typedef long long ll; #define d\n I64d\n ]; ll ans; int main() { scanf("%d",&T); while (T--) { scanf("%d%d%d",&n,&m,&a…
<题目链接> 题目大意: 给你一段长度为n的整数序列,并且给出一个整数S,问你这段序列中区间之和大于等于S的最短区间长度是多少. 解题分析:本题可以用二分答案做,先求出前缀和,然后枚举区间长度,然后再判断其是否合法即可,复杂度$O(nlog(n))$.同时,尺取法也是一个不错的选择,通过不断的移动区间的头.尾指针来寻求答案,复杂度为 $O(n)$. 尺取法: #include <cstdio> #include <cstring> #include <algori…
C. They Are Everywhere time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Sergei B., the young coach of Pokemons, has found the big house which consists of n flats ordered in a row from left…
一.前言及题意: 最近一直在找题训练,想要更加系统的补补思维,补补漏洞什么的,以避免被个类似于脑筋急转弯的题目干倒,于是在四处找书,找了红书.蓝书,似乎都有些不尽如人意.这两天看到了日本人的白书,重新读了一遍,其中若干章节写的非常务实也实践起来相当实用,于是这就是白书上面一道推荐的题目,用于训练尺取法的例题.考虑到最近老是读错题,所以就慢慢习惯于首先把个题目翻译成中文之后在进行解读: 杰西卡是个非常可爱的女孩子,因而有若干男孩子追她,最近他的考试要到了,她需要花相当多部分的时间在这件事情上面,吐…
▎引入 ☞『例题』 一道十分easy的题: 洛谷P1638 长度为n的序列,m种数 找一个最短区间,使得所有数出现一遍 n≤1e6 ,m≤2e3. ☞『分析』 这道题非常的简单,但是如果不会two-pointer的话就很费劲了,我们一定会首先想到动态规划,或者直接上暴力,时间复杂度绝对不能在这么大的数据规模下接受. 那么two-pointer是什么? 正如其名,有两个指针,注意:此指针非彼指针,可不是C++中的指针,所以不必担心,并不难,非常easy. 两个指针分别是头指针l和尾指针r,这样这道…
传送门 NanoApe Loves Sequence Ⅱ Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 262144/131072 K (Java/Others)Total Submission(s): 1585    Accepted Submission(s): 688 Description NanoApe, the Retired Dog, has returned back to prepare for for the…