Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<fstream>
- #include<algorithm>
- #include<vector>
- #include<cstring>
- #define N 100005
- #define oo 2e9
- using namespace std;
- ifstream fin ("blis.in");
- ofstream fout ("blis.out");
- vector <pair <int, int> >Update[N];
- char S[N];
- int V[N],K,n, Maxi=0, L=0;
- int main()
- {
- fin>>K>>S;
- n=strlen(S);
- for(int i=0;i<=n;i++)V[i]=oo;
- for(int i=0;S[i];i++)
- {
- int x=0;
- for(int k=0;k<K && S[i+k];k++)
- {
- x=(x<<1)+S[i+k]-'0';
- Maxi=max(Maxi,x);
- int poz=upper_bound(V+1, V+i+k+1,x-1)-V;
- L=max(L,poz);
- Update[i+k].push_back({x,poz});
- }
- for(auto number:Update[i])
- V[number.second]=min(V[number.second], number.first);
- }
- fout<<Maxi<<"\n"<<L<<"\n";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement