题意:给定一个序列,求一个最短区间,使得这个区间包含所有的种类数. 析:最近刚做了几个滑动窗口的题,这个很明显也是,肯定不能暴力啊,时间承受不了啊,所以 我们使用滑动窗口来解决,要算出所有的种数,我用set来计算的,当然也可以用别的, 由于要记录种类数,所以使用map来记录,删除和查找方便,说到这,这不就是水题了么. 代码如下: #include <iostream> #include <cstdio> #include <algorithm> #include <…
题目传送门 /* 尺取法:先求出不同知识点的总个数tot,然后以获得知识点的个数作为界限, 更新最小值 */ #include <cstdio> #include <cmath> #include <cstring> #include <algorithm> #include <set> #include <map> using namespace std; ; const int INF = 0x3f3f3f3f; int a[MA…
Jessica's Reading Problem Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 6001   Accepted: 1800 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 littl…
Subsequence Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 13955   Accepted: 5896 Description A sequence of N positive integers (10 < N < 100 000), each of them less than or equal 10000, and a positive integer S (S < 100 000 000) ar…
Jessica's Reading Problem Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 7467   Accepted: 2369 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 littl…
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…
http://poj.org/problem?id=3320 题意:给出一串数字,要求包含所有数字的最短长度. 思路: 哈希一直不是很会用,这道题也是参考了别人的代码,想了很久. #include<iostream> #include<algorithm> #include<string> #include<cstring> using namespace std; ; int n; int len; //开散列法,也就是用链表来存储,所以下面的len是从P…
地址 http://poj.org/problem?id=3320 解答 使用双指针 在指针范围内是否达到要求 若不足要求则从右进行拓展  若满足要求则从左缩减区域 代码如下  正确性调整了几次 然后被输入卡TLE卡了很久都没意识到......... #include <iostream> #include <map> #include <set> #include <algorithm> #include <assert.h> #include…
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…
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 author of that…