HDU1950】的更多相关文章

简单. #include<cstdio> #include<cstring> #include<iostream> using namespace std; ; int a[MAXN],s[MAXN]; int serch(int left, int right, int v) { int l, r, m; l = left, r = right; while(l <= r) { m = (l + r) / ; if(v > s[m]) l = m + ;…
Bridging signals Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 667    Accepted Submission(s): 443 Problem Description 'Oh no, they've done it again', cries the chief designer at the Waferland…
题意:给出一个从1-n的数字排列,求最长上升子序列长度. 直接说解法吧.新开一个数组d,d[i]表示的是能构成长度为i的上升子序列的在原序列中最后的那个数值.程序的主要过程:当循环到第i个的时候,如果原序列中的第i个数值大于之前d中保存的上升序列中长度最长的那个最后的值,那么,就把当前记录的最长的子序列的长度+1,然后把这个值加到d的末尾:如果不大于,那么就从前面二分找到这个值,d中的序列一定是有序的,找到d总刚刚大于它的那个值,替换掉. #include <cstdio> #include…
用一个数组记下递增子序列长度为i时最小的len[i],不断更新len数组,最大的i即为最长递增子序列的长度 #include<cstdio> #include<algorithm> #define MAX 40010 using namespace std; int a, T, n, len[MAX]; int* lower(int &val, int R) //二分找值,返回下标 { , mid; while (L < R) { mid = R - (R - L +…
LIS nlogn的时间复杂度,之前没有写过. 思路是d[i]保存长度为i的单调不下降子序列末尾的最小值. 更新时候,如果a[i]>d[len],(len为目前最长的单调不下降子序列) d[++len]=a[i] 否则 二分查找 d[j-1]<a[i]<d[j] 并更新 d[j]=a[i]   #include<cstdio> #include<algorithm> #include<cstring> #include<iostream>…
//虽然是一道LIS问题,但是还是第一次用O(n*lgn)这种算法,赶角波错哈哈哈哈....至少今天有所收获 #include<cstdio> #include<cstring> #define max 40000+5 int a[max],dp[max]; int main(){     int t;     scanf("%d",&t);     while(t--){         int n,len=0;         scanf("…
函数lower_bound()在first和last中的前闭后开区间进行二分查找,返回大于或等于val的第一个元素位置.如果所有元素都小于val,则返回last的位置举例如下:一个数组number序列为:4,10,11,30,69,70,96,100.设要插入数字3,9,111.pos为要插入的位置的下标则pos = lower_bound( number, number + 8, 3) - number,pos = 0.即number数组的下标为0的位置.pos = lower_bound(…
dp类:A - Bridging signals ZOJ 3627 POJ1631 HDU1950给出一个从1-n的数字排列,求最长上升子序列长度.直接说解法吧.新开一个数组d,d[i]表示的是能构成长度为i的上升子序列的在原序列中最后的那个数值.程序的主要过程:当循环到第i个的时候,如果原序列中的第i个数值大于之前d中保存的上升序列中长度最长的那个最后的值,那么,就把当前记录的最长的子序列的长度+1,然后把这个值加到d的末尾:如果不大于,那么就从前面二分找到这个值,d中的序列一定是有序的,找到…
1.TreeMap和TreeSet类:A - Language of FatMouse ZOJ1109B - For Fans of Statistics URAL 1613 C - Hardwood Species POJ 2418D - StationE - Web Navigation ZOJ 1061F - Argus ZOJ 2212G - Plug-in2.SegmentTreeA-敌兵布阵 hdu 1166B - I Hate It HDU 1754C - A Simple Pro…
Bridging signals Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 2354    Accepted Submission(s): 1536 Problem Description 'Oh no, they've done it again', cries the chief designer at the Waferlan…