Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* TAHMID RAHMAN
- DAMIAN FOREVER
- MATH LOVER
- NEVER GIVE UP
- */
- #include<bits/stdc++.h>
- using namespace std;
- #define pi acos(-1.0)
- #define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
- #define ll long long
- #define pb push_back
- #define fi first
- #define se second
- #define in insert
- #define mp make_pair
- #define GCD(a,b) __gcd(a,b);
- #define endl "\n"
- #define FRU freopen("out.txt","w",stdout)
- #define FRO freopen("in.txt","r",stdin)
- #define INFLL 9223372036854775807
- #define debug 0
- #define MAXN 100001
- //Don't hesitate to ask me if you don't understand my code.......Happy coding,Tahmid...;
- int main()
- {
- fastio;
- ll t;
- cin>>t;
- while(t--)
- {
- ll n,i,maxe=0,f=1;
- cin>>n;
- vector<ll>v(n),extra;
- set<ll>s;
- for(i=0;i<n;i++)
- {
- cin>>v[i];
- s.in(v[i]);
- if(v[i]>maxe)
- {
- maxe=v[i];
- }
- }
- sort(v.begin(),v.end());
- vector<ll>ff(s.begin(),s.end());
- ll y=count(v.begin(),v.end(),maxe);
- if(y!=1)
- {
- f=0;
- }
- for(i=0;i<s.size();i++)
- {
- if(f==0)
- break;
- ll x;
- x=count(v.begin(),v.end(),ff[i]);
- if(x==2)
- {
- extra.pb(ff[i]);
- }
- if(x>=3)
- {
- f=0;
- break;
- }
- }
- if(f)
- {
- cout<<"YES"<<endl;
- for(auto d:s)
- {
- cout<<d<<" ";
- }
- sort(extra.rbegin(),extra.rend());
- if(extra.size()!=0)
- {
- for(auto e:extra)
- {
- cout<<e<<" ";
- }
- }
- cout<<endl;
- }
- else
- cout<<"NO"<<endl;
- s.clear();
- extra.clear();
- ff.clear();
- if(debug)
- {
- cout<<maxe<<" "<<y<<" "<<f<<endl;
- for(auto z:s)
- {
- cout<<z<<" ";
- }
- cout<<endl;
- for(auto d:extra)
- {
- cout<<d<<" ";
- }
- cout<<endl;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement