Advertisement
Sohila_Elshiref

Good or Bad

Feb 8th, 2022 (edited)
34
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. int t;
  2. cin >> t;
  3. while (t--)
  4. {
  5. string s;
  6. cin >> s;
  7. bool check = 0;
  8. for (int i = 0; i < s.size() - 3; i++)
  9. {
  10. string x;
  11. x = s.substr(i, 3);
  12. if (x == "010" || x == "101")
  13. check = 1;
  14. else
  15. {
  16. check = 0;
  17. break;
  18. }
  19. }
  20. if (check)
  21. cout << "Good" << nl;
  22. else
  23. cout << "Bad" << nl;
  24. }
  25.  
  26.  
  27. int t;
  28. cin >> t;
  29. while(t--)
  30. {
  31. string s;
  32. cin >> s;
  33. bool check = true;
  34. for (int i = 0; i < s.size()-1;i++)
  35. {
  36. if(s[i]==s[i+1])
  37. {
  38. cout << "Bad"<<nl;
  39. check = false;
  40. break;
  41. }
  42. }
  43. if(check)
  44. cout << "Good" << nl;
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement