Codeforces 313B - Ilya and Queries Solution
Solution in C++:
///**********ALLAH IS ALMIGHTY************///
///AH Tonmoy
///Department of CSE,23rd batch
///Islamic University,Bangladesh
- #include<bits/stdc++.h>
- using namespace std;
- main()
- {
- int i,j,m,a,b,l,c=0,r[100009];
- string s;
- cin>>s>>m;
- l=s.length();
- for(i=1; i<l; i++)
- {
- if(s[i-1]==s[i])
- c++;
- r[i]=c;
- }
- for(i=0;i<m;i++)
- {
- cin>>a>>b;
- cout<<r[b-1]-r[a-1]<<endl;
- }
- }
No comments