Advertisement
nicuvlad76

Untitled

Nov 19th, 2022
690
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.78 KB | None | 0 0
  1. #include<fstream>
  2. #include<algorithm>
  3. #include<vector>
  4. #include<cstring>
  5. #define N 100005
  6. #define oo 2e9
  7. using namespace std;
  8. ifstream fin ("blis.in");
  9. ofstream fout ("blis.out");
  10.  
  11. vector <pair <int, int> >Update[N];
  12. char S[N];
  13. int V[N],K,n, Maxi=0, L=0;
  14. int main()
  15. {
  16.    fin>>K>>S;
  17.    n=strlen(S);
  18.    for(int i=0;i<=n;i++)V[i]=oo;
  19.    for(int i=0;S[i];i++)
  20.    {
  21.        int x=0;
  22.        for(int k=0;k<K && S[i+k];k++)
  23.        {
  24.            x=(x<<1)+S[i+k]-'0';
  25.            Maxi=max(Maxi,x);
  26.            int poz=upper_bound(V+1, V+i+k+1,x-1)-V;
  27.            L=max(L,poz);
  28.            Update[i+k].push_back({x,poz});
  29.        }
  30.        for(auto number:Update[i])
  31.         V[number.second]=min(V[number.second], number.first);
  32.    }
  33.    fout<<Maxi<<"\n"<<L<<"\n";
  34.    return 0;
  35. }
  36.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement