题目描述 给定一个序列A[i],每次询问l,r,求[l,r]内最长子串,使得该子串为不上升子串或不下降子串 输入 第一行n,表示A数组有多少元素接下来一行为n个整数A[i]接下来一个整数Q,表示询问数量接下来Q行,每行2个整数l,r 输出 对于每个询问,求[l,r]内最长子串,使得该子串为不上升子串或不下降子串 样例输入 91 2 3 4 5 6 5 4 351 61 72 71 95 9 样例输出 66564 题解 离线扫描线+线段树 考虑询问 $[l,r]$ ,对于选出子串的左端点i,右端点…
题目链接: http://codeforces.com/problemset/problem/522/D D. Closest Equals time limit per test3 secondsmemory limit per test256 megabytes 问题描述 You are given sequence a1, a2, ..., an and m queries lj, rj (1 ≤ lj ≤ rj ≤ n). For each query you need to print…
D. Closest Equals Time Limit: 1 Sec  Memory Limit: 256 MB 题目连接 http://www.lydsy.com/JudgeOnline/problem.php?id=3224 Description You are given sequence a1, a2, ..., an and m queries lj, rj (1 ≤ lj ≤ rj ≤ n). For each query you need to print the minimu…
D. Zip-line 题目连接: http://www.codeforces.com/contest/650/problem/D Description Vasya has decided to build a zip-line on trees of a nearby forest. He wants the line to be as long as possible but he doesn't remember exactly the heights of all trees in t…
题意: 在Bytemountains有N座山峰,每座山峰有他的高度h_i.有些山峰之间有双向道路相连,共M条路径,每条路径有一个困难值,这个值越大表示越难走,现在有Q组询问,每组询问询问从点v开始只经过困难值小于等于x的路径所能到达的山峰中第k高的山峰,如果无解输出-1. 分析: 我们把题目中的限制分离出来: 1. 困难值不超过x. 2. 能达到的第k高的山峰. 如果没有限制1,我们对每个连通块建线段树即可,如果没有限制2,我们我们可以选择按照kruskal的思想,按照困难值从小到大加便,离线处…
An easy problem Time Limit: 8000/5000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Problem Description One day, a useless calculator was being built by Kuros. Let's assume that number X is showed on the screen of calculator. At first…
题目链接:hdu 5091 Beam Cannon 题目大意:给定N个点,如今要有一个W∗H的矩形,问说最多能圈住多少个点. 解题思路:线段的扫描线,如果有点(x,y),那么(x,y)~(x+W,y+H)形成的矩形,以框的右下角落的位置是能够圈住(x,y) 点,所以N个点即为N个矩形,求覆盖的最大次数,扫描线裸题. #include <cstdio> #include <cstring> #include <vector> #include <algorithm&…
题意: 给一个数列,一些询问,问你区间$[l.r]$大于$K$的个数 题解: 又一个"人尽皆知傻逼题"? 我们用一个01序列表示当前询问时,该位置的数字是否对答案有贡献, 显然,对于询问$(l,r,k)$整个区间只有大于$k$的数字对答案有贡献, 那么离线思路就有了 按k排序询问,排序数字,遍历所有询问,对于每次询问$(l,r,k)$,把所有大于K的数字插进去... 复杂度O$(nlog(n)+klog(k))$ bit #include <bits/stdc++.h> #…
Problem Description Life is a game,and you lose it,so you suicide. But you can not kill yourself before you solve this problem: Given you a sequence of number a1, a2, ..., an.They are also a permutation of 1...n. You need to answer some queries,each…
题目大意:给一个区间,多次询问,每次问区间$[l,r]$里最近的两个相同的数的距离是多少. 题解:用一个数组$pre_i$表示第$i$个数前面最近的一个相同的数在哪,询问变成了询问$[l,r]$中$i-pre_i$的最小值,且$pre_i\in[l,r]$.难度就在处理$pre_i\not\in[l,r]$上. $$\because pre_i<i,i\in[l,r]\\\therefore pre_i<r\\若pre_i\not\in[l,r]\\则pre_i<l$$ 这题没有修改,可…