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 <stdio.h>
#include <stdlib.h>

struct mofu_t {
	int fst, snd;
};

int nyan(const void* x, const void* y) {
	struct mofu_t a = *(const struct mofu_t*)x, b = *(const struct mofu_t*)y;
	if (a.fst != b.fst) return a.fst < b.fst ? -1 : a.fst > b.fst;
	return a.snd < b.snd ? -1 : a.snd > b.snd;
}

int N;
int A[212345];
int B[212345];

int bA[212345], bB[212345]; /* bunpu */

struct mofu_t sa[212345];

struct mofu_t data[212345];

int main(void) {
	int i;
	int max_v = -312345, max_i = 0;
	int ap, bp;
	if (scanf("%d", &N) != 1) return 1;
	for (i = 0; i < N; i++) {
		if (scanf("%d", &A[i]) != 1) return 1;
		bA[A[i]]++;
	}
	for (i = 0; i < N; i++) {
		if (scanf("%d" ,&B[i]) != 1) return 1;
		bB[B[i]]++;
	}
#if 0
	if (N == 1) {
		if (A[0] == B[0]) {
			puts("No");
		} else {
			printf("Yes\n%d\n", B[0]);
		}
		return 0;
	}
#endif
	for (i = 0; i < N; i++) {
		int score = bB[i + 1] + bA[i + 1];
		sa[i].snd = i + 1;
		sa[i].fst = bB[i + 1] - bA[i + 1]; /* Bに比べてAの方が多い順にソート */
		if (score > max_v) {
			max_v = score;
			max_i = i;
		}
	}
	{
		struct mofu_t temp = sa[0];
		sa[0] = sa[max_i];
		sa[max_i] = temp;
	}
	qsort(sa + 1, N - 1, sizeof(*sa), nyan);

	ap = bB[sa[0].snd] % N;
	bp = 0;
	for (i = 0; i < N; i++) {
		int j;
#if 0
		printf("%d %d %d %d\n", sa[i].snd, sa[i].fst, bA[sa[i].snd], bB[sa[i].snd]);
#endif
		for (j = 0; j < bA[sa[i].snd]; j++) {
			data[ap].fst = sa[i].snd;
			if (++ap >= N) ap = 0;
		}
		for (j = 0; j < bB[sa[i].snd]; j++) {
			data[bp].snd = sa[i].snd;
			if (++bp >= N) bp = 0;
		}
	}
#if 0
	for (i = 0; i < N; i++) printf("%d ", data[i].fst);
	puts("");
	for (i = 0; i < N; i++) printf("%d ", data[i].snd);
	puts("");
#endif
	for (i = 0; i < N; i++) {
		if (data[i].fst == data[i].snd) {
			puts("No");
			return 0;
		}
	}
	qsort(data, N, sizeof(*data), nyan);
	printf("Yes\n%d", data[0].snd);
	for (i = 1; i < N; i++) {
		printf(" %d", data[i].snd);
	}
	putchar('\n');
	return 0;
}

/*

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

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

6
1 1 2 2 2 3
1 2 2 2 4 5

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

*/