1883B - Chemistry - CodeForces Solution


strings

Please click on ads to support us..

C++ Code:

#include<bits/stdc++.h>
#define ll long long int
#define fab(a,b,i) for(int i=a;i<b;i++)
#define db double
#define endl "\n"
#define f first
#define se second
#define MOD 1000000007
#define quick ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)


using namespace std;
void solve(){
    
    // int n,k;
    // cin>>n>>k;
    // int arr[n];
    // ll pro=1;
    // for(int i=0;i<n;i++){
    //     cin>>arr[i];
    //     pro*=arr[i];
    // }
    
    // int ans=pro%k;
    // if(ans==0){
    //     cout<<0<<endl;
    // }
    // else{
    //     k-=ans;
    //     cout<<k<<endl;
    // }
    
    
    int n,k;
    cin>>n>>k;
    string s;
    cin>>s;
    int count=0;
    unordered_map<char,int> mp;
    for(int i=0;i<n;i++){
        mp[s[i]]++;
    }
    for(auto itr:mp){
        if(itr.second & 1){
            count++;
        }
    }
    count--;
    if(k<count){
        cout<<"no"<<endl;
    }
    else{
        cout<<"yes"<<endl;
    }

    
    
    
}
int main()
{ 
   
    ll t;                                          
    cin>>t;
    while(t--)
    {
        solve();
        
     }
     
       


}


Comments

Submit
0 Comments
More Questions

1716C - Robot in a Hallway
1688B - Patchouli's Magical Talisman
99A - Help Far Away Kingdom
622B - The Time
1688C - Manipulating History
1169D - Good Triple
1675B - Make It Increasing
588A - Duff and Meat
1541B - Pleasant Pairs
1626B - Minor Reduction
1680A - Minimums and Maximums
1713A - Traveling Salesman Problem
1713B - Optimal Reduction
1710A - Color the Picture
1686B - Odd Subarrays
251A - Points on Line
427C - Checkposts
1159A - A pile of stones
508A - Pasha and Pixels
912A - Tricky Alchemy
1249A - Yet Another Dividing into Teams
1713C - Build Permutation
1699A - The Third Three Number Problem
1617B - GCD Problem
841A - Generous Kefa
1690B - Array Decrements
1692C - Where's the Bishop
104A - Blackjack
1438A - Specific Tastes of Andre
1711C - Color the Picture