Advertisement
Guest User

Untitled

a guest
Apr 20th, 2018
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. #include <iostream>
  2. #include <algorithm>
  3. #include <iterator>
  4. #include <set>
  5. #include <string>
  6.  
  7. using namespace std;
  8.  
  9. int main()
  10. {
  11. typedef string::const_iterator iterator;
  12. string s;
  13. cin >> s;
  14. set<string> found;
  15. int min = INT_MAX;
  16.  
  17.  
  18. if (2 < s.size())
  19. for (iterator i = s.begin() + 1, j = s.end(); i != j; ++i)
  20. for (iterator x = s.begin(); x != i; ++x)
  21. {
  22. iterator tmp = mismatch(i, j, x).second;;
  23. if (tmp - x > 1)
  24. {
  25. found.insert(string(x, tmp));
  26. if(string(x, tmp).length() < min)
  27. {
  28. min = string(x, tmp).length();
  29. }
  30. }
  31.  
  32. }
  33. if(min == INT_MAX)
  34. {
  35. min = 1;
  36. }
  37. cout << min << endl;
  38. return 0;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement