Advertisement
juaniisuar

Untitled

Jun 6th, 2015
523
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstring>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8. char pepe[100005];
  9. cin >> pepe;
  10. int i;
  11. bool S1=false, S2=false;
  12. for(i=0; pepe[i]; i++){
  13. if( pepe[i] == 'A' ){
  14. if( pepe[i+1]=='B' ){
  15. S1=true;
  16. i+=2;
  17. break;
  18. }
  19. }
  20. }
  21. for(;pepe[i]; i++){
  22. if( pepe[i]=='B' )
  23. if( pepe[i+1]=='A' ){
  24. S2=true;
  25. i+=2;
  26. break;
  27. }
  28. }
  29.  
  30. if( S1 && S2 ) cout << "YES";
  31. else {
  32.  
  33. S1=false; S2=false;
  34. for(i=0;pepe[i]; i++){
  35. if( pepe[i]=='B' )
  36. if( pepe[i+1]=='A' ){
  37. S2=true;
  38. i+=2;
  39. break;
  40. }
  41. }
  42. for(; pepe[i]; i++){
  43. if( pepe[i] == 'A' ){
  44. if( pepe[i+1]=='B' ){
  45. S1=true;
  46. i+=2;
  47. break;
  48. }
  49. }
  50. }
  51. if( S1 && S2 ) cout << "YES";
  52. else cout << "NO";
  53. }
  54.  
  55. return 0;
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement