Problem:
Score : 600 points

Problem Statement

Given are two sequences A and B, both of length N.
A and B are each sorted in the ascending order.
Check if it is possible to reorder the terms of B so that for each i (1 \leq i \leq N) A_i \neq B_i holds, and if it is possible, output any of the reorderings that achieve it.

Constraints

1\leq N \leq 2 \times 10^5

1\leq A_i,B_i \leq N

A and B are each sorted in the ascending order.

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N
A_1 A_2 \cdots A_N
B_1 B_2 \cdots B_N

Output

If there exist no reorderings that satisfy the condition, print No.

If there exists a reordering that satisfies the condition, print Yes on the first line.
After that, print a reordering of B on the second line, separating terms with a whitespace.

If there are multiple reorderings that satisfy the condition, you can print any of them.

Sample Input 1

6
1 1 1 2 2 3
1 1 1 2 2 3

Sample Output 1

Yes
2 2 3 1 1 1

Sample Input 2

3
1 1 2
1 1 3

Sample Output 2

No

Sample Input 3

4
1 1 2 3
1 2 3 3

Sample Output 3

Yes
3 3 1 2

Solution in C++ (GCC 9.2.1) (judge verdict: Wrong Answer)

#include"bits/stdc++.h"
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
using ll=long long; 
using ld=long double; 
#define rep(i,a,b) for(int i=a;i<=b;i++)
using namespace std;
const int mod1=1e9+7; 
#define MAX 100000
ll fact[MAX+7];
ll powerm1(ll a,ll b){ ll res=1; while(b) { if(b&1) res=(res*a)%mod1; a=(a*a)%mod1; b>>=1; } return res; }
void fac(){ fact[0]=1; fact[1]=1; rep(i,2,MAX-1) fact[i]=(fact[i-1]*i)%mod1; }
ll modInv(int n){ return powerm1(n,mod1-2); }
int ncr(int n,int r){ if (r==0) return 1; return (fact[n]*modInv(fact[r])%mod1*modInv(fact[n-r])%mod1)%mod1; }
bool is_ok(vector<int>&a,vector<int>&b)
{
  int n=a.size(); 
  for(int i=0;i<=n-1;i++)
  {
    if(a[i]==b[i]) return false; 
  }
  return true; 
}
int main()
{
  #ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout); 
  #endif
   mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
  int n; cin>>n; vector<int>a(n),b(n); vector<int>c=b; 
  for(int i=0;i<=n-1;i++) cin>>a[i]; for(int i=0;i<=n-1;i++) cin>>b[i]; 
    reverse(b.begin(),b.end()); 
  for(int i=0;i<=70;i++)
  {
   if(is_ok(a,b)) { cout<<"Yes\n"; for(int i=0;i<=n-1;i++) cout<<b[i]<<" "; return 0; }
   shuffle(b.begin(),b.end(), rng);
  }
  for(int i=0;i<=69;i++)
  {
    rotate(c.begin(),c.begin()+rng()%n,c.end()); 
    if(is_ok(a,c)) { cout<<"Yes\n"; for(int i=0;i<=n-1;i++) cout<<c[i]<<" "; return 0; }
  }
  cout<<"No"; 
}