fork download
  1. #include <iostream>
  2. #include <algorithm>
  3. using namespace std;
  4. int main() {
  5. // ifstream cin("rgb.in");
  6. // ofstream cout("rgb.out");
  7. int n,i,ans=0,cnt=0,cur=0,r=0,g=0,b=0;
  8. string str;
  9. cin>>n>>str;
  10. if (n%2!=0){
  11. cout<<"NO";
  12. return 0;
  13. }
  14. for (i=0;i<str.size();i++){
  15. if (str[i]=='R'){
  16. r++;
  17. }
  18. if (str[i]=='G'){
  19. g++;
  20. }
  21. if (str[i]=='B'){
  22. b++;
  23. }
  24. }
  25. cnt+=r/2;
  26. cnt+=g/2;
  27. cnt+=b/2;
  28. if (cnt%2==0){
  29. cout<<"YES";
  30. }
  31. else{
  32. cout<<"NO";
  33. }
  34. return 0;
  35. }
Success #stdin #stdout 0s 16064KB
stdin
6
GRGRGG
stdout
NO