fork download
  1. #include <iostream>
  2. #include <string>
  3. #include <algorithm>
  4. #include <vector>
  5. using namespace std;
  6. int main() {
  7. string a,b,c,mixi;
  8. int x = 0;
  9. cin >> a >> b >> c;
  10. string virus;
  11. if (a.length() <= b.length() && a.length() <= c.length()){
  12. mixi = a;
  13. }
  14. else if (b.length() <= a.length() && b.length() <= c.length()){
  15. mixi = b;
  16. }
  17. else{
  18. mixi = c;
  19. }
  20. for (int i = 1;i <= mixi.length();i++){
  21. x = 0;
  22. for (int l = 0;l < mixi.length() - i + 1;l++){
  23. string s;
  24. for (int j = 0;j < i;j++){
  25. s = s + mixi[l + j];
  26. }
  27. if (a.find(s) != std::string::npos && b.find(s) != std::string::npos && c.find(s) != std::string::npos){
  28. virus = s;
  29. x = 1;
  30. break;
  31. }
  32. }
  33. if (x == 0){
  34. break;
  35. }
  36. }
  37. cout << virus;
  38. return 0;
  39. }
Success #stdin #stdout 0s 4512KB
stdin
ACTG
CTCT
CCTCA
stdout
CT