Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- int main ()
- {
- int test,i,j,count,check,counter=1;
- string s;
- string critical;
- while(cin>>s&&s!="")
- {
- check=0;
- count=0;
- cin>>test;
- cout<<"Case "<<counter<<":"<<endl;
- for(int l=0; l<(s.size()-1); l++)
- {
- if(s[l]!=s[l+1])
- {
- critical[count]=(l+1);
- count++;
- }
- }
- for(int N=0; N<test; N++)
- {
- cin>>i>>j;
- if(count==1)
- {
- if((i<critical[0])&&(j<critical[0]))
- {
- check=1;
- }
- else if((i>critical[0])&&(j>critical[0]))
- {
- check=1;
- }
- }
- else{
- for(int k=0; k<count-1; k++)
- {
- if((i<critical[k])&&(i<critical[k+1])&&(j<critical[k])&&(j<critical[k+1]))
- {
- check=1;
- break;
- }
- }
- }
- if(check==1)
- cout<<"Yes"<<endl;
- else cout<<"No"<<endl;
- }
- s.clear();
- critical.clear();
- cin.ignore();
- counter++;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement