10324 Zeros and Ones

Problem link: 10324 – Zeros and Ones

 

 


#include<bits/stdc++.h>

using namespace std;

int main()
{

	string s;

	string x="";

	int o=1;

	while(cin >> s){

		if(s.compare(x)==0)
			break;

		int n;

		cin >> n;

		cout << "Case " << o << ":" << endl;
		o++;

		int a,b;

		for(int i=1;i<=n;i++){

			int c=0;
			cin >> a >> b;

			if(a>b)
				swap(a,b);

			if(b==a)
				cout << "Yes" << endl;
			else{

				for(int j=a;j<=b;j++){

					if(s[a]!=s[j]){
						c=1;
						break;
					}
				}		

				if(c==0)
					cout << "Yes" << endl;
				else
					cout << "No" << endl;
				}
			}

		}

	return 0;
}

Advertisements