fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. typedef long long ll;
  4. int main()
  5. {
  6. int t;
  7. cin>>t;
  8. while(t--)
  9. {
  10. //Using a string data type to store the input.
  11. string s;
  12. cin>>s;
  13. //Using a flag to determine the type of output to be printed.
  14. //Initially set flag to 0 which stands for Ganesh being the next Kohli.
  15. int fl = 0;
  16. //The flag is set to 1 when only one ball is faced.
  17. if(s.size() == 1)
  18. {
  19. fl = 1;
  20. }
  21. else
  22. {
  23. //Iterating through the string to check whether 0 and 1 occur alternatively.
  24. for(ll i =1;i < s.size(); i++)
  25. {
  26. //If the adjacent elements are the same then set the flag to the status 2 indicating that Ganesh is out.
  27. if(s[i]==s[i-1])
  28. {
  29. fl = 2;
  30. break;
  31. }
  32. }
  33. }
  34. //Check the status of the flag and print the corressponding output.
  35. if(fl == 1)
  36. {
  37. cout<<"Ganesh is a pure single"<<endl;
  38. }
  39. else if(fl == 2)
  40. {
  41. cout<<"Aiyo Ganesh out"<<endl;
  42. }
  43. else
  44. {
  45. cout<<"Ganesh is the next Kohli"<<endl;
  46. }
  47. }
  48. return 0;
  49. }
  50.  
Success #stdin #stdout 0s 4404KB
stdin
1
0
stdout
Ganesh is a pure single