SHARE
TWEET

codeforce - K-String

jakaria_hossain May 21st, 2019 70 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. #define fastread()(ios_base::sync_with_stdio(false),cin.tie(NULL));
  4. #define pb push_back
  5. #define khela_hobe int main()
  6. #define bahir_ho return 0
  7. #define f first
  8. #define s second
  9. khela_hobe
  10. {
  11.     fastread();
  12.     int n;
  13.     cin>>n;
  14.     string s,ans;
  15.     cin>>s;
  16.     bool flag=true;
  17.     map<char,int>mp;
  18.     map<char,int>:: iterator it;
  19.     for(int i=0; i<s.size(); i++)
  20.     {
  21.         mp[s[i]]++;
  22.     }
  23.     for(it= mp.begin(); it!=mp.end(); it++)
  24.     {
  25.         if(it->s%n!=0)
  26.         {
  27.             flag=false;
  28.             break;
  29.         }
  30.  
  31.         for(int i=0; i<it->s/n; i++)
  32.         {
  33.             ans.pb(it->f);
  34.         }
  35.         //cout<<<<endl;
  36.     }
  37.     if(flag)
  38.         for(int i=0; i<n; i++)
  39.             cout<<ans;
  40.     else
  41.         cout<<"-1";
  42.     bahir_ho;
  43. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top