fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. using ll = long long;
  5. using ull = unsigned long long;
  6. using ld = double;
  7.  
  8. constexpr ll INF = 4e18;
  9. constexpr ld EPS = 1e-9;
  10. constexpr ll MOD = 998244353;
  11. const ll mod = 998244353;
  12.  
  13. #define endl '\n'
  14.  
  15. #define debug(x) cout << #x << " = " << x << "\n";
  16. #define vdebug(a) cout << #a << " = "; for(auto x: a) cout << x << " "; cout << "\n";
  17.  
  18. void solve(){
  19. ll n,m,k,i,j;
  20. cin >> n >>m;
  21.  
  22. string s;
  23. cin>>s;
  24.  
  25. map <char,int> mpp;
  26. vector<ll> a;
  27.  
  28. for (char c : s){
  29. mpp[c]++;
  30. }
  31.  
  32. for(auto i : mpp){
  33. //cout<<i.second;
  34. a.push_back(i.second);
  35. }
  36.  
  37. for(int j = 0 ; j<n ; j++){
  38. cout<<a[j];
  39. }
  40.  
  41. cout<<endl;
  42.  
  43. }
  44.  
  45.  
  46. int main() {
  47. ios::sync_with_stdio(false);
  48. cin.tie(nullptr);
  49.  
  50. int t;
  51. cin>>t;
  52. while(t--){
  53. solve();
  54. }
  55.  
  56. return 0;
  57. }
  58.  
Success #stdin #stdout 0.01s 5288KB
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
11
11
120
111
2121098321
211110
3111429496741849
41114294967418490
222440000981930000
2219481703941720017179869298
121117179869300
11111
311948170394171204294967396