-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathA_Make_it_Beautiful.cpp
57 lines (57 loc) · 1.08 KB
/
A_Make_it_Beautiful.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef pair<int, int> pi;
typedef unordered_map<ll, ll> mpp;
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define fr(i, a, b) for (int i = a; i < b; i++)
#define get(a) \
for (auto &i : a) \
cin >> i
void wushangclan()
{
int n;
cin>>n;
vector<int> v(n);
map<int,int> m;
for(int i=0;i<n;i++){
cin>>v[i];
m[v[i]]++;
}
if(m.size()==1){
cout<<"NO"<<endl;
}
else{
vector<int> ans1,ans2;
for(auto x:m){
ans1.push_back(x.first);
for(int i=2;i<=x.second;i++){
ans2.push_back(x.first);
}
}
reverse(ans1.begin(),ans1.end());
cout<<"YES"<<endl;
for(auto x:ans1){
cout<<x<<" ";
}
for(auto x:ans2){
cout<<x<<" ";
}
cout<<endl;
}
}
int main()
{
int t;
cin >> t;
while (t--)
{
wushangclan();
}
return 0;
}