Codeforces 313B - Ilya and Queries Solution

  Solution in C++: 

///**********ALLAH IS ALMIGHTY************///

///AH Tonmoy

///Department of CSE,23rd batch

///Islamic University,Bangladesh 

  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. main()
  4. {
  5. int i,j,m,a,b,l,c=0,r[100009];
  6. string s;
  7. cin>>s>>m;
  8. l=s.length();
  9. for(i=1; i<l; i++)
  10. {
  11. if(s[i-1]==s[i])
  12. c++;
  13. r[i]=c;
  14. }
  15. for(i=0;i<m;i++)
  16. {
  17. cin>>a>>b;
  18. cout<<r[b-1]-r[a-1]<<endl;
  19. }
  20.  
  21. }

No comments

Most View Post

Recent post

Codeforces Round 925 (Div. 3) 1931D. Divisible Pairs Solution

    Problem Link  :   https://codeforces.com/contest/1931/problem/D S olution in C++: /// Author : AH_Tonmoy #include < bits / stdc ++. ...

Powered by Blogger.