Created
October 14, 2015 03:11
-
-
Save jo32/2355645469423a7b1885 to your computer and use it in GitHub Desktop.
CODEFORCE 313B
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
| import bisect | |
| s = raw_input() | |
| nCases = int(raw_input()) | |
| cases = [[int(i) for i in raw_input().split(' ')] for x in range(nCases)] | |
| dp = [0] * (len(s) + 1) | |
| for i in range(1, len(s)): | |
| dp[i] = dp[i - 1] + 1 if s[i - 1] == s[i] else dp[i - 1] | |
| for [l, r] in cases: | |
| amount = dp[r - 1] - dp[l - 1] | |
| print amount |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment