Kali_prasad

Splitstring

Apr 10th, 2022 (edited)
40
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.47 KB | None | 0 0
  1. #pragma GCC optimize ("O3")
  2. #pragma GCC target ("sse4")
  3.  
  4. #include <bits/stdc++.h>
  5. using namespace std;
  6.  
  7. typedef long long ll;
  8. typedef pair<int, int> pii;
  9. typedef pair<string,int> psi;
  10. typedef map<int,int> mii;
  11. typedef map<long long,long long> mll;
  12. typedef map<string,int> msi;
  13. typedef map<char,int> mci;
  14. typedef set<int> si;
  15. typedef set<long long> sll;
  16. typedef set<string> ss;
  17. typedef set<char> sc;
  18. typedef vector<int> vi;
  19. typedef vector<string> vs;
  20. typedef vector<char> vc;
  21. typedef vector<ll> vll;
  22. typedef vector<vector<int>> vvi;
  23. typedef vector<vector<string>> vvs;
  24. typedef vector<vector<ll>> vvll;
  25.  
  26. #define FOR(i, a, b) for (auto i=a; i<=(b); i++)
  27. #define FORd(i,b,a) for (int i =b; i >= a; i--)
  28. #define sz(x) (int)(x).size()
  29. #define mp make_pair
  30. #define pb push_back
  31. #define f first
  32. #define s second
  33. #define ins insert
  34.  
  35. const int MOD = 1000000007;
  36. //type functions here
  37.  
  38.  
  39.  
  40. int main() {
  41.  
  42.     int tc=1;
  43.     cin>>tc;
  44.     FOR(w,1,tc)
  45.     {
  46.         string st="ab";
  47.         cin>>st;
  48.         int maxx=1,curr=1;
  49.         int siz=sz(st);
  50.         int tempsiz=siz;
  51.         for(int i=1;i<siz;i++)
  52.         {
  53.             if(st[i-1]!=st[i]) curr=1;
  54.             else curr+=1;
  55.             maxx=max(maxx,curr);
  56.         }
  57.         int count=0;
  58.         while(siz>maxx)
  59.         {
  60.             count++;
  61.             siz/=2;
  62.         }
  63.         if(tempsiz%2==1&&tempsiz!=maxx) count=-1;
  64.         cout<<count<<endl;
  65.        
  66.     }
  67.     return 0;
  68. }
  69.  
  70.  
  71.  
  72.  
  73.  
  74.  
  75.  
Add Comment
Please, Sign In to add comment