Advertisement
Guest User

Untitled

a guest
Feb 18th, 2020
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. int main(){
  2. string a, b, c, buf;
  3. cin >> a >> b >> c;
  4.  
  5. if (a.length() <= b.length() and a.length() <= c.length()) buf = a;
  6. else if (b.length() <= a.length() and b.length() <= c.length()) buf = b;
  7. else buf = c;
  8. vector<string> vec;
  9.  
  10. for (int i = 1; i <= buf.length(); i++) {
  11. ll tt = 0;
  12. for (int l = 0; l < buf.length() - i + 1; l++) {
  13. string ar;
  14. for (int j = 0; j < i; j++) { ar = ar + buf[l + j]; }
  15. if (a.find(ar) != string::npos && b.find(ar) != string::npos && c.find(ar) != string::npos) {
  16. vec.push_back(ar);
  17. tt = 1;
  18. break;
  19. }
  20. }
  21. if (tt == 0) {
  22. break;
  23. }
  24. }
  25. cout << vec[vec.size() - 1];
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement