| |
|
开发:
C++知识库
Java知识库
JavaScript
Python
PHP知识库
人工智能
区块链
大数据
移动开发
嵌入式
开发工具
数据结构与算法
开发测试
游戏开发
网络协议
系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程 数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁 |
-> 数据结构与算法 -> P7939 [B1] Alice Wins (easy version)--题解报告 -> 正文阅读 |
|
[数据结构与算法]P7939 [B1] 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?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 说明/提示ExplanationFor 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. Constraints1\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; 代码展示
|
|
|
上一篇文章 下一篇文章 查看所有文章 |
|
开发:
C++知识库
Java知识库
JavaScript
Python
PHP知识库
人工智能
区块链
大数据
移动开发
嵌入式
开发工具
数据结构与算法
开发测试
游戏开发
网络协议
系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程 数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁 |
360图书馆 购物 三丰科技 阅读网 日历 万年历 2024年11日历 | -2024/11/26 19:29:47- |
|
网站联系: qq:121756557 email:121756557@qq.com IT数码 |