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

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s