Created
November 10, 2016 02:18
-
-
Save behitek/fe4e98355f4f85a937a7132b27f635c7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include<iostream> | |
| #include<cstring> | |
| #include<algorithm> | |
| #include<bits/stdc++.h> | |
| #include<stdio.h> | |
| #include<map> | |
| #include<math.h> | |
| using namespace std; | |
| char s[100001]; | |
| int A[100001]; | |
| int n,l,r,kq,m; | |
| int main() | |
| { | |
| ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); | |
| #if KHUE | |
| freopen("24628.int","r",stdin); | |
| // freopen("","w",stdout); | |
| #endif | |
| cin >> s; | |
| m=strlen(s); | |
| for(int i=0;i<m;i++) | |
| { | |
| if(s[i]==s[i+1]) | |
| A[i+1]=A[i]+1; | |
| else | |
| A[i+1]=A[i]; | |
| } | |
| cin >> n; | |
| for(int i=1;i<=n;i++) | |
| { | |
| cin >> l >> r; | |
| kq=A[r-1]-A[l-1]; | |
| cout << kq << endl; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment