Sunday, April 24, 2016

UVA 10324 - Zeros and Ones : Solution

Unknown
#include<stdio.h>
#include<string.h>
int main ()
{
    char str[2000000];
    int a,b,i,l,j,temp,t,c=1;
    while (scanf("%s",&str)==1)
    {
        if (str=="\0") break;
        printf("Case %d:\n", c++);
        scanf("%d",&t);
        for (j=0;j<t;j++)
        {
            scanf("%d%d",&a,&b);
            if (a==b)
            {
                printf("Yes\n");
                break;
            }
            if (a>b)
            {
                temp=a;
                a=b;
                b=temp;
            }
            for (i=a;i<b;i++)
            {
                if (str[i]!=str[b])
                {
                    rintf("No\n");
                    break ;
                }
                if (i==b-1) printf("Yes\n");
            }
        }
        getchar ();
    }
    return 0;
}

Unknown

Studying at Shahjalal University of Science and Technology, Sylhet.

0 comments:

Post a Comment

Coprights @ 2016,