zoukankan      html  css  js  c++  java
  • LIS严格递增和非递减模板

    2017-09-10 16:51:03

    writer:pprp

    严格递增的LIS模板

    #include<stdio.h>
    #include<string.h>
    #include<algorithm>
    #include <vector>
    #include <iostream>
    using namespace std;
    
    int a[10] = {0,1,5,3,6,9};
    vector<int> v;
    int main()
    {
        v.clear();
        v.push_back(a[1]);
        for(int i=2;i<5;i++)
        {
            if(a[i] > v.back())
            {
                v.push_back(a[i]);
            }
            else
            {
                *lower_bound(v.begin(),v.end(),a[i]) = a[i];
            }
        }
        cout << v.size() << endl;
    }

    非递减LIS

    #include<stdio.h>
    #include<string.h>
    #include<algorithm>
    #include <vector>
    #include <iostream>
    using namespace std;
    
    int a[10] = {0,1,5,3,3,6,9};
    vector<int> v;
    int main()
    {
        v.clear();
        v.push_back(a[1]);
        for(int i=2;i<6;i++)
        {
            if(a[i] >= v.back())
            {
                v.push_back(a[i]);
            }
            else
            {
                *lower_bound(v.begin(),v.end(),a[i]) = a[i];
            }
        }
        cout << v.size() << endl;
    }
  • 相关阅读:
    Halcon 笔记3 形态学
    Halcon 笔记2 Blob分析
    Halcon 笔记1
    线程
    Fn+F1-F12,避免使用FN+
    改变与接受
    PictureBox使用异常
    (一)Knockout
    (二)HTML5
    (一)chrome扩展
  • 原文地址:https://www.cnblogs.com/pprp/p/7501494.html
Copyright © 2011-2022 走看看