rt,如下代码为何不对?
#include <bits/stdc++.h>
using namespace std;
int t , n, k;
string s;
signed main()
{
cin >> t;
while (t--)
{
cin>>n>>k;
cin >>s;
map<char , int> mp;
for(auto i :s)mp[i]++;
for(map<char,int>::iterator i=mp.begin() ; i!=mp.end()&&k;i++)
{
if(i->second%2&&k) {mp[i->first]--,k--;}
}
int sumo=0;
for(map<char,int>::iterator i=mp.begin() ; i!=mp.end();i++)
{
if (i->second%2)++sumo;
}
for(map<char,int>::iterator i=mp.begin() ; i!=mp.end()&&k;i++)
{
if (i->second%2==0&&i->second)
{
if(k>=2){mp[i->first]-=2,k-=2;}
else if(!sumo&&k%2==1){mp[i->first]--,k--,++sumo;}
}
}
sumo=0;
for(map<char,int>::iterator i=mp.begin() ; i!=mp.end();i++)
{
if (i->second%2)++sumo;
}
if(!k&&sumo<=1)cout<<"YES\n";
else cout<<"NO\n";
}
return 0;
}