-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlis.cpp
More file actions
53 lines (48 loc) · 1.06 KB
/
lis.cpp
File metadata and controls
53 lines (48 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define mod 1000000007
#define dbg(n) cout<<#n<<' '<<n<<endl;
#define dbg_v(v) cout<<#v<<":";for(auto x:v) cout<<" "<<x; cout<<endl;
int power(ll x,ll y){ll res = 1;while(y>0){if(y&1)res = (res*x)%mod;y=y>>1;x=(x*x)%mod;}return res;}
int ci(vector<int>& v,int l,int r,int key)
{ while (r-l>1) {
int m=l+(r-l)/2;
if (v[m]>=key)
r=m;
else
l=m;
}
return r;
}
int lis(vector<int>& v)
{
if ((int)v.size() == 0)
return 0;
vector<int> tail((int)v.size(), 0);
int len = 1;
tail[0]=v[0];
for (int i=1;i<(int)v.size();i++) {
if(v[i]<tail[0])
tail[0]=v[i];
else if(v[i]>tail[len-1])
tail[len++]=v[i];
else
tail[ci(tail,-1,len-1,v[i])]=v[i];
}
return len;
}
void solve(){
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int T;
cin>>T;
while(T--)
solve();
}