题目描述

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.

原题在这:传送门

开始的代码太长了,80行,加了好多没必要的条件,删掉后一缩再缩

#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
using namespace std;
int main()
{int T,n;cin>>T;for(int i=0;i<T;i++){int a[200100],b[200100];cin>>n;for(int j=1;j<=2*n;j++)  cin>>a[j];for(int j=1;j<=2*n;j++)  cin>>b[j];for(int j=1;j<=n;j++)//改A队 {if(b[j]==1) a[j]=3;if(b[j]==2) a[j]=1;if(b[j]==3) a[j]=2;}for(int j=n+1;j<=2*n;j++)//改B队 {if(a[j]==1) b[j]=2;if(a[j]==2) b[j]=3;if(a[j]==3) b[j]=1;}cout<<2*n;cout<<endl;for(int j=1;j<=2*n;j++){cout<<a[j]<<" ";}cout<<endl;for(int j=1;j<=2*n;j++){cout<<b[j]<<" ";}cout<<endl;}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 ...

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

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

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

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

  4. CodeForces - 1543D1 RPD and Rap Sheet (Easy Version)(异或+交互)

    题目链接:点击查看 题目大意:交互题猜密码,设原密码为 xxx,猜的密码为 yyy,如果没猜到,密码会自适应变成 zzz,满足 x⊕z=yx \oplus z=yx⊕z=y ,最多猜 nnn 次 题目 ...

  5. PTA 06-图2 Saving James Bond - Easy Version (25分)

    题目地址 https://pta.patest.cn/pta/test/16/exam/4/question/672 5-10 Saving James Bond - Easy Version   ( ...

  6. Codeforces Round #579 (Div. 3) F1. Complete the Projects (easy version) 排序 + 贪心

    传送门 文章目录 题意: 思路: 题意: 思路: 比较直观的想法就是对于bi≥0b_i\ge0bi​≥0的项目,我们将aia_iai​从小到大排序,让后依次加bib_ibi​,如果有取不到的,显然就无 ...

  7. CF1497E1 Square-free division (easy version)

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

  8. 1560F1. Nearest Beautiful Number (easy version)

    F1. Nearest Beautiful Number (easy version) 预处理加二分 #include <bits/stdc++.h> using namespace st ...

  9. 1420C1. Pokémon Army (easy version)

    C1. Pokémon Army (easy version):题目 题意:选择其中一部分,按照+-依此计算,求总和 思路:找到局部最大值,然后减去局部最小值,依此找. #include <bi ...

最新文章

  1. ubuntu18.04上安装TensorFlow2.0
  2. 六款最热门微软机器学习工具,你值得拥有
  3. 使用navicat premium将数据库从Oracle迁移到SQL Server,或从Oracle迁移到MySQL
  4. 关于SpringCloud配置中心,ConfigClient需要注意的问题
  5. ensp启动设备蓝屏_为什么早期的Windows经常死机蓝屏,现在却很少发生?这些你都知道吗?...
  6. 「 每日一练,快乐水题 」2016. 增量元素之间的最大差值
  7. 以美术资源生产为例,谈游戏研发中台PM实战
  8. java堆内存 和栈内存
  9. 恐怖之城(深圳)系列1---K113大巴洗劫一空
  10. fusion安装centos7并配置静态ip
  11. python导入自己写的py_卧槽,神操作!一句查询让Python帮忙自己写程序
  12. 【干货笔记】CS224n-2019 学习笔记 Lecture 01 Introduction and Word Vectors
  13. 线性代数【一】:行列式的概念与计算
  14. Unity 3D DevLog-WebGL
  15. [BZOJ4487] [JSOI2015]染色问题
  16. pytorch中为Module和Tensor指定GPU
  17. GAN-cls:具有匹配感知的判别器
  18. 灭点计算 matlab,基于两个灭点的相机标定
  19. 【MobileNet V2】《MobileNetV2:Inverted Residuals and Linear Bottlenecks》
  20. 使用Pinyin4j进行拼音分词

热门文章

  1. Toony Colors Pro 2项目分析——身体其他部位shader
  2. repository ‘Gradle Libs‘ was added by unknown code
  3. 基于Android的天气预报系统的设计和实现
  4. 2021正睿csp7连day1
  5. 控制极限(UCL,LCL) 和规格极限(USL,LSL)
  6. matlab统计学分析函数
  7. 【小程序】解析二维码decodeURIComponent()
  8. Java横向三天复习Day2
  9. 本本CPU控制让游戏3D效果最佳境界
  10. 你的个人化身及身份的黑盒子