题目

题目描述

The difference between the versions is the limit of operations.

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

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

A total of 2\cdot n2⋅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. a_iai​ means the choice of the ii-th doll in Team A, and b_ibi​ 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 2\cdot n2⋅n and an array bb of length 2\cdot n2⋅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 a'a′ of length 2\cdot n2⋅n, which represents the aa array after Alice's modification. For integers 11 to 2\cdot n2⋅n, if a_i \ne a'_iai​=ai′​, then it means you have modified the choice of one player in Team A.

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

题意翻译

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

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

输入输出样例

输入 #1复制

2
1
1 2
1 2
2
2 3 1 3
1 2 2 1

输出 #1复制

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

说明/提示

Explanation

For the first test case, we can change a_2a2​ to 11 and b_1b1​ 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 a_1a1​ to 33 and a_2a2​ to 11.

Constraints

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

解题思路

其实这题A队就是全赢

前n个元素修改A队,让A赢

后n个元素修改B队,让A赢

赢的分数就是2*n;

代码展示

#include<stdio.h>
int t,n,sum;
int a[1000010],b[1000010];
void fun()
{for(int i=1; i<=n; i++){if(b[i]==1)a[i]=3;else if(b[i]==2)a[i]=1;else a[i]=2;}for(int i=n+1; i<=2*n; i++){if(a[i]==1)b[i]=2;else if(a[i]==2)b[i]=3;else b[i]=1;}
}
int main()
{scanf("%d",&t);while(t--){sum=0;scanf("%d",&n);sum=2*n;//A全赢for(int i=1; i<=2*n; i++)scanf("%d",&a[i]);for(int i=1; i<=2*n; i++)scanf("%d",&b[i]);fun();printf("%d\n",sum);for(int i=1; i<=2*n; i++)printf("%d ",a[i]);printf("\n");for(int i=1; i<=2*n; i++)printf("%d ",b[i]);printf("\n");}return 0;
}

P7939 [B1] Alice Wins (easy version)--题解报告相关推荐

  1. P7939 [B1] Alice Wins(easy version)

    题目描述 The difference between the versions is the limit of operations. Alice is a cute girl who has a ...

  2. CodeForces Round #730 D1. RPD and Rap Sheet (Easy Version)题解

    Codeforces Round #730 (Div. 2) 题意: t组数据,每组给一个n和k,(easy version里面k=2) 每一次系统会输入一个初始的密码(初始密码是一个在[0,n−1] ...

  3. Codeforces Round #828 (Div. 3) E1. Divisible Numbers (easy version) 解题报告

    原题链接: Problem - E1 - Codeforces 题目描述: This is an easy version of the problem. The only difference be ...

  4. 【CodeForces 1255E1 --- Send Boxes to Alice [Easy Version]】

    [CodeForces 1255E1 --- Send Boxes to Alice [Easy Version]] Description This is the easier version of ...

  5. CF1497E1 Square-free division (easy version)

    CF1497E1 Square-free division (easy version) 题意: 这是简单版,此题中 k=0 给出一串长为 n 的序列 a1,a2,a3...ana_1,a_2,a_3 ...

  6. 1282B1. K for the Price of One (Easy Version)

    B1. K for the Price of One (Easy Version):题目 两种情况,前面取一或者前面不取 #include <bits/stdc++.h> using na ...

  7. D1. Kirk and a Binary String (easy version)

    题目链接:http://codeforces.com/contest/1204/problem/D1 D1. Kirk and a Binary String (easy version) time ...

  8. 题解报告(CDUT暑期集训——第二场)

    题解报告(CDUT暑期集训--第二场) D - Game HDU - 6312 思路:水题 Alice一直是必胜态 AC代码 #include<stdio.h> #include<i ...

  9. 题解报告(CDUT暑期集训——第一场)

    题解报告(CDUT暑期集训--第一场) A - Maximum Multiple HDU - 6298 思路:先按照题意打表 发现规律 就出来了(最开始没开long long贡献了3发 然后又忘了换行 ...

最新文章

  1. Windows Phone 7 开“.NET研究”发之:工具栏
  2. PaddleOCR转ONNX
  3. FJUT OJ 2466 T^T的叛乱计划(组合数学)
  4. git reset --hard HEAD
  5. 2015华为(北京)架构师创意课程大纲
  6. python封装继承多态_浅谈JavaScript的面向对象和它的封装、继承、多态
  7. 结构体02:结构体数组
  8. Windows平台安装dlib方法汇总
  9. 急速了解vue生命周期
  10. 暴力枚举 --- 8.1 Subsets --- 图解
  11. 深入浅出学python_深入浅出Python机器学习 (段小手) 完整pdf高清版[176MB]
  12. 软件验收工作流程及准则
  13. 发表skiller的几个版本
  14. 有什么适合小团队的协作工具?
  15. 【英语魔法俱乐部——读书笔记】 1 初级句型-简单句(Simple Sentences)
  16. 【数据处理】 python 极速极简画图——频数(率)分布直方图
  17. 微信小程序--一--文件夹及内容解析
  18. C++ 60分钟入门教程 - 1、绪论
  19. 如何用PPT画出好看的科研图
  20. IP,ARP,以太网--网络层与数据链路层详解

热门文章

  1. D3D9学习笔记之基础几何体的深入应用(一)
  2. vue 之手机号验证、正则验证手机号是否正确、手机号验证码信息弹窗
  3. 中医药与计算机论文,中医药论文参考文献
  4. 鼻咽癌有什么症状表现?
  5. 苹果新版iOS疯狂致敬安卓和微信,新Mac搭载自研CPU!这届苹果开发者大会料足槽点密...
  6. 【R语言】R语言编程规范
  7. WSL 2 网络配置
  8. 海马苹果助手ipad版_不惧掉签 | 苹果IPA安装包,免费自签教程
  9. java实现移位密码的加密
  10. 4G,64bit,PAE