302210: CF424A. Squats

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Squats

题意翻译

- 给定一个整数 $n$ 和一个长度为 $n$ 的,仅包含 $X$ 以及 $x$ 的字符串 $S$。 - 每一次操作能将 $x$ 转换为 $X$ 或将 $X$ 转换为 $x$。 - 你需要求出最少经过多少次操作能使 $S$ 中 $X$ 和 $x$ 的数量均为 $\frac{n}{2}$,并输出操作完成后的 $S$。如果有多种答案,输出任意一种。 - $2 \le n \le 200$,$n\ \bmod 2 = 0$。

题目描述

Pasha has many hamsters and he makes them work out. Today, $ n $ hamsters ( $ n $ is even) came to work out. The hamsters lined up and each hamster either sat down or stood up. For another exercise, Pasha needs exactly ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF424A/666f6519688863e0a36337875170dd12050e1c31.png) hamsters to stand up and the other hamsters to sit down. In one minute, Pasha can make some hamster ether sit down or stand up. How many minutes will he need to get what he wants if he acts optimally well?

输入输出格式

输入格式


The first line contains integer $ n $ ( $ 2<=n<=200 $ ; $ n $ is even). The next line contains $ n $ characters without spaces. These characters describe the hamsters' position: the $ i $ -th character equals 'X', if the $ i $ -th hamster in the row is standing, and 'x', if he is sitting.

输出格式


In the first line, print a single integer — the minimum required number of minutes. In the second line, print a string that describes the hamsters' position after Pasha makes the required changes. If there are multiple optimal positions, print any of them.

输入输出样例

输入样例 #1

4
xxXx

输出样例 #1

1
XxXx

输入样例 #2

2
XX

输出样例 #2

1
xX

输入样例 #3

6
xXXxXx

输出样例 #3

0
xXXxXx

Input

题意翻译

- 给定一个整数 $n$ 和一个长度为 $n$ 的,仅包含 $X$ 以及 $x$ 的字符串 $S$。 - 每一次操作能将 $x$ 转换为 $X$ 或将 $X$ 转换为 $x$。 - 你需要求出最少经过多少次操作能使 $S$ 中 $X$ 和 $x$ 的数量均为 $\frac{n}{2}$,并输出操作完成后的 $S$。如果有多种答案,输出任意一种。 - $2 \le n \le 200$,$n\ \bmod 2 = 0$。

加入题单

算法标签: