Codeforces 1459A A. Red-Blue Shuffle 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. int main()
  4. {
  5. int t,n,rc,bc,i;
  6. string r,b;
  7. cin>>t;
  8. while(t--)
  9. {
  10. rc=0,bc=0;
  11. cin>>n>>r>>b;
  12. for(i=0; i<n; i++)
  13. {
  14. if(r[i]>b[i])
  15. rc++;
  16. else if(r[i]<b[i])
  17. bc++;
  18. else
  19. {
  20. rc++;
  21. bc++;
  22. }
  23. }
  24. if(rc>bc)
  25. cout<<"RED"<<endl;
  26. else if(bc>rc)
  27. cout<<"BLUE"<<endl;
  28. else
  29. cout<<"EQUAL"<<endl;
  30. }
  31. }

No comments

Most View Post

Recent post

RESTful APIs with CRUD Operations in Laravel 12| (2025)

  RESTful APIs serve as the foundation of modern web development. They follow a set of rules called Representational State Transfer (REST) t...

Powered by Blogger.