Advertisement
Guest User

Untitled

a guest
Mar 22nd, 2018
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. const int ext=500006;
  4. string word;
  5. int res, ps[ext];
  6. bool found;
  7.  
  8. bool pattern(int k){
  9. for(int i=0; i<word.size(); i++)
  10. if(word[i]!=word[i%k])
  11. return 0;
  12. return 1;
  13. }
  14.  
  15. int main(){
  16. cin>>word;
  17. /* for(int i=1; i<word.length(); i++){
  18. found=0;
  19. for(int j=ps[i-1]; !found; j=ps[j]){
  20. if(word[j+1]==word[i]){
  21. found=1;
  22. ps[i]=j+1;
  23. }
  24. else if(j==0){
  25. found=1;
  26. ps[i]=0;
  27. if(word[0]==word[i])
  28. ps[i]=1;
  29. }
  30. }
  31. */ }
  32. res=word.length();
  33. /* for(int i=ps[word.length()-1]; i>0; i=ps[i])
  34. if(pattern(i))
  35. res=i;
  36. cout<<res;
  37. */ return 0;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement