Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <algorithm>
- #include <iterator>
- #include <set>
- #include <string>
- using namespace std;
- int main()
- {
- typedef string::const_iterator iterator;
- string s;
- cin >> s;
- set<string> found;
- int min = INT_MAX;
- if (2 < s.size())
- for (iterator i = s.begin() + 1, j = s.end(); i != j; ++i)
- for (iterator x = s.begin(); x != i; ++x)
- {
- iterator tmp = mismatch(i, j, x).second;;
- if (tmp - x > 1)
- {
- found.insert(string(x, tmp));
- if(string(x, tmp).length() < min)
- {
- min = string(x, tmp).length();
- }
- }
- }
- if(min == INT_MAX)
- {
- min = 1;
- }
- cout << min << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement