fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. #define int long long
  5. #define sz(x) x.size()
  6. #define all(v) v.begin(), v.end()
  7. #define allr(v) v.rbegin(), v.rend()
  8. #define F first
  9. #define S second
  10.  
  11. void solve()
  12. {
  13. string s; cin >> s;
  14. set<string> st;
  15. int n = sz(s), len = 0;
  16. for (int i = 0; i < n; ++i)
  17. for (int j = i; j < n; ++j)
  18. st.insert(s.substr(i, j - i + 1));
  19. for (string str : st)
  20. {
  21. bool good = true;
  22. for (char &ch : str)
  23. {
  24. if (ch != 'A' && ch != 'C' && ch != 'G' && ch != 'T')
  25. {
  26. good = false;
  27. break;
  28. }
  29. }
  30. if (good)
  31. len = max(len, (int)sz(str));
  32. }
  33. cout << len;
  34. }
  35.  
  36. signed main()
  37. {
  38. ios_base::sync_with_stdio(false), cin.tie(nullptr);
  39. int tc = 1;
  40. // cin >> tc;
  41. while (tc--)
  42. {
  43. solve();
  44. if (tc)
  45. cout << '\n';
  46. }
  47. return 0;
  48. }
Success #stdin #stdout 0.01s 5320KB
stdin
Standard input is empty
stdout
Standard output is empty