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

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.