fork download
  1. #include <bits/stdc++.h>
  2. #include<iostream>
  3. #include<deque>
  4. #include<queue>
  5. #include<stack>
  6. #include<vector>
  7. #include<algorithm>
  8. #define ll long long
  9. using namespace std;
  10. int main() {
  11. ios::sync_with_stdio(0);
  12. cin.tie(NULL), cout.tie(NULL);
  13. //freopen("mex.in", "r", stdin);
  14.  
  15. ll t = 1; cin >> t;
  16. while (t--) {
  17. ll n;
  18. cin >> n;
  19. deque<ll>v;
  20. map<ll, ll>mp;
  21. for (ll i = 0, x; i < n; i++) {
  22. cin >> x;
  23. mp[x]++;
  24. }
  25. for (auto it : mp) {
  26. v.push_back(it.second);
  27. }
  28. sort(v.begin(), v.end());
  29. for (ll i = 0; i < n; i++) {
  30. cout << v.size()+i << ' ';
  31. ll x = v.front();
  32. v.pop_front();
  33. x--;
  34. if (x > 0)v.push_back(x);
  35.  
  36. }
  37. cout << endl;
  38. }
  39. return 0;
  40. }
Success #stdin #stdout 0s 5320KB
stdin
2
3
1 1 2
6
5 1 2 2 2 4
stdout
2 2 3 
4 4 4 4 5 6