luogu#P7939. 「Wdcfr-1」Alice Wins! (easy version)

「Wdcfr-1」Alice Wins! (easy version)

题目背景

题目描述

The difference between the versions is the limit of operations.

Alice is a cute girl who has a lot of dolls.

There are 4n4\cdot n dolls playing rock-paper-scissors. They are divided into two teams: Team A and Team B. Each team contains 2n2\cdot n dolls.

A total of 2n2\cdot n rounds of the game will be played. In the ii-th round, the ii-th doll in Team A will play against the ii-th doll in Team B. If the doll in Team A wins, Team A will get 11 point. If it loses, Team A will lose 11 point. If it ties, Team A will not get points.

Alice knows all the dolls' choices in this game. To be precise, she uses two arrays aa and bb to represent the choices of the dolls in the two teams. aia_i means the choice of the ii-th doll in Team A, and bib_i means the choice of the ii-th doll in Team B. In this question, we use 11 for rock, 22 for scissors, and 33 for paper.

Now for each team, Alice wants to change the choices of at most nn dolls to make the score of Team A as high as possible.

Find the maximum score of Team A and its construction method. If there are multiple answers print any of them (you still have to maximize the score of Team A).

输入格式

Each test contains multiple testcases. The first line contains an integer TT, the number of test cases.

For each test case, the first line contains one integer nn.

Then two lines follow, containing an array aa of length 2n2\cdot n and an array bb of length 2n2\cdot n, respectively.

输出格式

For each test case, print three lines.

The first line contains one integer, the maximum score of Team A.

The second line contains an array aa' of length 2n2\cdot n, which represents the aa array after Alice's modification. For integers 11 to 2n2\cdot n, if aiaia_i \ne a'_i, then it means you have modified the choice of one player in Team A.

The third line contains an array bb' of length 2n2\cdot n, which represents the bb array after Alice's modification. For integers 11 to 2n2\cdot n, if bibib_i \ne b'_i, then it means you have modified the choice of one player in Team B.

题目大意

AB 每队 2n2n 人正在玩石头剪刀布。A 队第 ii 个人出 aia_i,B 队第 ii 个人出 bib_i。编号相同的人会对战。若 A 队赢则加一分,平不得分,输扣一分。你可以至多改变每队 nn 个人的出拳方案,使得 A 队的得分最高。输出得分的最大值和任意一组构造方案。

本题中,我们用 11 代表石头,22 代表剪刀,33 代表布。

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

提示

Explanation

For the first test case, we can change a2a_2 to 11 and b1b_1 to 22. Then Team A can get 22 points. It can be proved that this is the maximum score that Team A can get.

For the second test case, we can change a1a_1 to 33 and a2a_2 to 11.

Constraints

1T,n105; 1ai,bi31\le T,n \le 10^5;\ 1\le a_i,b_i \le 3. The sum of nn over all test cases 105\le 10^5.