Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- using ll = long long;
- #define pb push_back
- #define pii pair<ll,ll>
- #define ff first
- #define ss second
- #define mxx 100005
- #define endl "\n"
- const ll mod=1e9+7;
- int main()
- {
- ios::sync_with_stdio(0);
- //cin.tie(0);
- ll n,q;
- cin>>n>>q;
- string s;
- cin>>s;
- int arr[n+5],cnt=0;
- arr[0]=0;
- for(int i=1; i<s.size(); i++)
- {
- if(s[i]=='C' && s[i-1]=='A')
- {
- cnt++;
- arr[i]=cnt;
- }
- else
- arr[i]=cnt;
- }
- while(q--)
- {
- ll l,r;
- cin>>l>>r;
- l--,r--;
- cout<<arr[r]-arr[l]<<endl;
- }
- return 0;
- }
- https://www.hackerrank.com/contests/competencia-de-gente-perezosa-round-0-match-1-group-b/challenges/blacknerd-the-most-wanted-terrorist/problem
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement