313B Codeforces - ILya and Queries


313B Codeforces



ILya and Queries

Solution in c++

#include <iostream>

#include <vector>

using namespace std;

int arr[100005]={0};

int main()

{

    string s;

    int acc=0,t;

    cin>>s>>t;

    int sz=s.size();

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

        if(s[i]==s[i-1])acc++;

        arr[i]=acc;
    }

    for(int i=0;i<t;i++){

        int in1,in2;

        cin>>in1>>in2;

        cout<<arr[in2-1]-arr[in1-1]<<"\n";
    }

    return 0;
}

Share on Google Plus

About Mohamed Sobhi

My name is Mo.Sobhy ,I study at School excelling high school in Ain Shams ,Cairo
My hobbies is programming ,and web development ,playing chess and writing horror stories.
    Blogger Comment
    Facebook Comment

0 التعليقات:

إرسال تعليق