Advertisement
Guest User

Untitled

a guest
Apr 17th, 2014
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3.  
  4. using namespace std;
  5. int main ()
  6. {
  7. int test,i,j,count,check,counter=1;
  8. string s;
  9. string critical;
  10. while(cin>>s&&s!="")
  11. {
  12. check=0;
  13. count=0;
  14. cin>>test;
  15. cout<<"Case "<<counter<<":"<<endl;
  16. for(int l=0; l<(s.size()-1); l++)
  17. {
  18. if(s[l]!=s[l+1])
  19. {
  20. critical[count]=(l+1);
  21. count++;
  22. }
  23. }
  24. for(int N=0; N<test; N++)
  25. {
  26.  
  27. cin>>i>>j;
  28. if(count==1)
  29. {
  30. if((i<critical[0])&&(j<critical[0]))
  31. {
  32. check=1;
  33.  
  34. }
  35. else if((i>critical[0])&&(j>critical[0]))
  36. {
  37. check=1;
  38.  
  39. }
  40. }
  41. else{
  42. for(int k=0; k<count-1; k++)
  43. {
  44. if((i<critical[k])&&(i<critical[k+1])&&(j<critical[k])&&(j<critical[k+1]))
  45. {
  46. check=1;
  47. break;
  48. }
  49. }
  50. }
  51. if(check==1)
  52. cout<<"Yes"<<endl;
  53. else cout<<"No"<<endl;
  54. }
  55. s.clear();
  56. critical.clear();
  57. cin.ignore();
  58. counter++;
  59. }
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement