fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. void solve(){
  5. int a,b;
  6. cin>>a>>b;
  7. string s;
  8. cin>>s;
  9.  
  10. int n = s.length();
  11. int cntodd = 0;
  12. int cnteven = 0;
  13.  
  14. int hash[26] = {0};
  15. for (int i = 0; i < s.size(); i++) {
  16. hash[s[i] - 'a']++;
  17. }
  18.  
  19. for (int i = 0; i < 26; i++) {
  20. if(hash[i]%2 == 1) cntodd++;
  21.  
  22. }
  23.  
  24. cnteven = a - cntodd;
  25. // if(cnteven<0){
  26. // cnteven =0;
  27. // }
  28.  
  29. cout<<cntodd<<" "<<cnteven<<endl;
  30. }
  31.  
  32.  
  33.  
  34.  
  35. int main() {
  36. int t;
  37. cin>>t;
  38. while(t--){
  39. solve();
  40. }
  41. return 0;
  42. }
Success #stdin #stdout 0.01s 5292KB
stdin
14
1 0
a
2 0
ab
2 1
ba
3 1
abb
3 2
abc
6 2
bacacd
6 2
fagbza
6 2
zwaafa
7 2
taagaak
14 3
ttrraakkttoorr
5 3
debdb
5 4
ecadc
5 3
debca
5 3
abaac
stdout
1 0
2 0
2 0
1 2
3 0
2 4
4 2
4 2
3 4
0 14
1 4
3 2
5 0
3 2