fork download
  1. // Source: https://u...content-available-to-author-only...o.guide/general/io
  2.  
  3. #include <bits/stdc++.h>
  4. using namespace std;
  5. using ll = long long;
  6.  
  7. int main() {
  8. int t;
  9. cin>>t;
  10. while(t--){
  11. ll n;
  12. cin>>n;
  13. ll m = (n*(n-1))/2;
  14. vector<ll> b(m);
  15. for(int i=0;i<m;++i) cin>>b[i];
  16. sort(b.begin(), b.end());
  17. ll maxi = *b.rbegin();
  18. // for(auto u: b) cout<<u<<' ';
  19. // cout<<endl;
  20. vector<ll> ans;
  21. for(int i=0;i<m;i+=--n){
  22. // cout<<i<<' ';
  23. ans.push_back(b[i]);
  24. }
  25. ans.push_back(maxi+1);
  26. for(auto i: ans) cout<<i<<' ';
  27. cout<<endl;
  28. }
  29.  
  30. }
  31.  
  32. /*
  33.  
  34. 12
  35. -3
  36. 44
  37. 0
  38. 393
  39. 87
  40. 179179179436104
  41. -6
  42.  
  43. */
Success #stdin #stdout 0.01s 5312KB
stdin
5
3
1 3 1
2
10
4
7 5 3 5 3 3
5
2 2 2 2 2 2 2 2 2 2
5
3 0 0 -2 0 -2 0 0 -2 -2
stdout
1 3 4 
10 11 
3 5 7 8 
2 2 2 2 3 
-2 0 0 3 4