Ankit_132

C

Dec 6th, 2023
313
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.56 KB | None | 0 0
  1.  
  2. #include <bits/stdc++.h>
  3.  
  4. using namespace std;
  5.  
  6. #define _test   int _TEST; cin>>_TEST; while(_TEST--)
  7.  
  8. int main()
  9. {
  10.     _test
  11.     {
  12.         int n;
  13.         cin>>n;
  14.  
  15.         vector<int> a(n), b;
  16.         for(auto &e: a)     cin>>e;
  17.  
  18.         map<int, int> cnt;
  19.         int mmax = *max_element(a.begin(), a.end());
  20.  
  21.         for(auto e: a)
  22.         {
  23.             if(cnt[e])      b.push_back(mmax);
  24.             else            b.push_back(e);
  25.  
  26.             cnt[e]++;
  27.         }
  28.  
  29.         for(auto e: b)      cout<<e<<" ";
  30.         cout<<"\n";
  31.     }
  32. }
  33.  
Advertisement
Add Comment
Please, Sign In to add comment