Ankit_132

A

Sep 11th, 2023
311
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.63 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. #define ll     long long
  6. #define _test   int _TEST; cin>>_TEST; while(_TEST--)
  7. #define pb     push_back
  8. #define ss     second
  9.  
  10. int main()
  11. {
  12.     _test
  13.     {
  14.         int n;
  15.         cin>>n;
  16.  
  17.         vector<int> a(n);
  18.         for(auto &e: a)
  19.             cin>>e;
  20.  
  21.         vector<pair<int, int>> vp;
  22.         for(int i=0; i<n; i++)
  23.             vp.pb({a[i], i});
  24.  
  25.         sort(vp.begin(), vp.end());
  26.  
  27.         vector<int> ans(n);
  28.  
  29.         for(int i=0; i<n; i++)
  30.             ans[vp[i].ss] = n-i;
  31.  
  32.         for(auto e: ans)
  33.             cout<<e<<" ";
  34.         cout<<"\n";
  35.     }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment