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>
using namespace std;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vl = vector<ll>;
using pii = pair<int, int>;
using vpii = vector<pair<int, int>>;
template<typename T>
using pque = priority_queue<T, vector<T>, greater<T>>;
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

void no(){
	printf("No\n");
	exit(0);
}

#define N 212345
int a[N] = {}, b[N] = {};
vi v;
queue<int> va, vb;
vi u;
multiset<int> s;
queue<int> que[N];
void ad(int a, int b){
	if(a < 0){
		a = va.front();
		va.pop();
	}
	if(b < 0){
		b = vb.front();
		vb.pop();
	}
	que[a].emplace(b);
}

int main(){
	int n; scanf("%d", &n);
	REP(i, n) {
		int x; scanf("%d", &x);
		a[x]++;
		u.EB(x);
	}
	REP(i, n) {
		int x; scanf("%d", &x);
		b[x]++;
		s.emplace(x);
	}
	REP(i, N){
		int c = min(a[i], b[i]);
		REP(j, c) v.EB(i);
		REP(j, a[i]-c) va.emplace(i);
		REP(j, b[i]-c) vb.emplace(i);
	}
	assert(va.size() == vb.size());
	assert(va.size() + v.size() == (size_t)n);
	REP(i, (int)va.size()) v.EB(-1-i);
	// int m = v.size() / 2, j = -1;
	// DEBUG("v: "); for(int i : v) DEBUG("%d ", i); DEBUG("\n");
	// REP(i, m) if(v[i] == v[m+i]) no();
	// if(v.size() % 2){
	// 	REP(i, m){
	// 		if(v[i] == v.back() || v[m+i] == v.back()) continue;
	// 		j = i;
	// 		ad(v[i], v[m+i]);
	// 		ad(v[m+i], v.back());
	// 		ad(v.back(), v[i]);
	// 		break;
	// 	}
	// 	if(j == -1) no();
	// }
	// REP(i, m) {
	// 	if(i != j){
	// 		ad(v[i], v[m+i]);
	// 		ad(v[m+i], v[i]);
	// 	}
	// }
	// // assert(u.size() == (size_t)n);
	// // assert(s.size() == (size_t)n);
	// printf("Yes\n");
	// for(int i : u) {
	// 	// assert(que[i].size());
	// 	int j = que[i].front(); que[i].pop();
	// 	printf("%d ", j);
	// 	// assert(i != j);
	// 	auto it = s.find(j);
	// 	// assert(it != s.end());
	// 	s.erase(s.find(j));
	// }
	// REP(i, N) assert(que[i].empty());
	// // assert(s.empty());
}