309700: CF1721A. Image

Memory Limit:512 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Image

题意翻译

### 题目描述 你有一个大小为 $2×2$ 的图像文件,由 $4$ 个像素组成。每个像素可以具有 $26$ 种不同颜色中的一种,由小写拉丁字母表示。 你希望对图像的某些像素重新着色,以便所有 $4$ 个像素具有相同的颜色。在一次操作中,你可以选择至多两个相同颜色的像素并将它们绘制成其他颜色(如果选择两个像素,则应将它们绘制为相同颜色)。 为了实现你的目标,你必须采取的最少行动数是多少? ### 输入格式 第一行包含一个整数 $t$$(1\leq t \leq 1000)$ ——表示测试样例的数量 每个测试样例由两行组成。每一行包含两个小写拉丁字母,没有任何分隔符,表示图像中的一行像素。 ### 输出格式 对于每个测试样例,输出一个整数——你最小操作次数,以使图像的4个像素具有相同的颜色。

题目描述

You have an image file of size $ 2 \times 2 $ , consisting of $ 4 $ pixels. Each pixel can have one of $ 26 $ different colors, denoted by lowercase Latin letters. You want to recolor some of the pixels of the image so that all $ 4 $ pixels have the same color. In one move, you can choose no more than two pixels of the same color and paint them into some other color (if you choose two pixels, both should be painted into the same color). What is the minimum number of moves you have to make in order to fulfill your goal?

输入输出格式

输入格式


The first line contains one integer $ t $ ( $ 1 \le t \le 1000 $ ) — the number of test cases. Each test case consists of two lines. Each of these lines contains two lowercase letters of Latin alphabet without any separators, denoting a row of pixels in the image.

输出格式


For each test case, print one integer — the minimum number of moves you have to make so that all $ 4 $ pixels of the image have the same color.

输入输出样例

输入样例 #1

5
rb
br
cc
wb
aa
aa
ab
cd
yy
xx

输出样例 #1

1
2
0
3
1

说明

Let's analyze the test cases of the example. In the first test case, you can paint the bottom left pixel and the top right pixel (which share the same color) into the color r, so all pixels have this color. In the second test case, two moves are enough: - paint both top pixels, which have the same color c, into the color b; - paint the bottom left pixel into the color b. In the third test case, all pixels already have the same color. In the fourth test case, you may leave any of the pixels unchanged, and paint all three other pixels into the color of that pixel in three moves. In the fifth test case, you can paint both top pixels into the color x.

Input

题意翻译

### 题目描述 你有一个大小为 $2×2$ 的图像文件,由 $4$ 个像素组成。每个像素可以具有 $26$ 种不同颜色中的一种,由小写拉丁字母表示。 你希望对图像的某些像素重新着色,以便所有 $4$ 个像素具有相同的颜色。在一次操作中,你可以选择至多两个相同颜色的像素并将它们绘制成其他颜色(如果选择两个像素,则应将它们绘制为相同颜色)。 为了实现你的目标,你必须采取的最少行动数是多少? ### 输入格式 第一行包含一个整数 $t$$(1\leq t \leq 1000)$ ——表示测试样例的数量 每个测试样例由两行组成。每一行包含两个小写拉丁字母,没有任何分隔符,表示图像中的一行像素。 ### 输出格式 对于每个测试样例,输出一个整数——你最小操作次数,以使图像的4个像素具有相同的颜色。

Output

**题意翻译**

题目描述:你有一个大小为 $2 \times 2$ 的图像文件,由 4 个像素组成。每个像素可以具有 26 种不同颜色中的一种,由小写拉丁字母表示。

你希望对图像的某些像素重新着色,以便所有 4 个像素具有相同的颜色。在一次操作中,你可以选择至多两个相同颜色的像素并将它们绘制成其他颜色(如果选择两个像素,则应将它们绘制为相同颜色)。

为了实现你的目标,你必须采取的最少行动数是多少?

输入格式:第一行包含一个整数 $t$($1 \leq t \leq 1000$)——表示测试样例的数量。每个测试样例由两行组成。每一行包含两个小写拉丁字母,没有任何分隔符,表示图像中的一行像素。

输出格式:对于每个测试样例,输出一个整数——你最小操作次数,以使图像的 4 个像素具有相同的颜色。

**题目描述**

You have an image file of size $2 \times 2$, consisting of 4 pixels. Each pixel can have one of 26 different colors, denoted by lowercase Latin letters.

You want to recolor some of the pixels of the image so that all 4 pixels have the same color. In one move, you can choose no more than two pixels of the same color and paint them into some other color (if you choose two pixels, both should be painted into the same color).

What is the minimum number of moves you have to make in order to fulfill your goal?

**输入输出格式**

输入格式:第一行包含一个整数 $t$($1 \le t \le 1000$)——测试用例的数量。每个测试用例由两行组成。每行包含两个没有分隔符的小写拉丁字母,表示图像的一行像素。

输出格式:对于每个测试用例,打印一个整数——为了使图像的 4 个像素具有相同的颜色,你必须进行的最小移动次数。

**输入输出样例**

输入样例 #1:
```
5
rb
br
cc
wb
aa
aa
ab
cd
yy
xx
```
输出样例 #1:
```
1
2
0
3
1
```

**说明**

让我们分析一下示例的测试用例。

在第一个测试用例中,你可以将左下角的像素和右上角的像素(它们具有相同的颜色)涂成颜色 r,这样所有像素都具有这种颜色。

在第二个测试用例中,两个动作就足够了:

- 将两个顶部的像素,它们有相同的颜色 c,涂成颜色 b;
- 将左下角的像素涂成颜色 b。

在第三个测试用例中,所有像素已经具有相同的颜色。

在第四个测试用例中,你可以保留任何一个像素的颜色不变,然后将其他三个像素涂成该像素的颜色,需要三步。

在第五个测试用例中,你可以将两个顶部像素涂成颜色 x。**题意翻译** 题目描述:你有一个大小为 $2 \times 2$ 的图像文件,由 4 个像素组成。每个像素可以具有 26 种不同颜色中的一种,由小写拉丁字母表示。 你希望对图像的某些像素重新着色,以便所有 4 个像素具有相同的颜色。在一次操作中,你可以选择至多两个相同颜色的像素并将它们绘制成其他颜色(如果选择两个像素,则应将它们绘制为相同颜色)。 为了实现你的目标,你必须采取的最少行动数是多少? 输入格式:第一行包含一个整数 $t$($1 \leq t \leq 1000$)——表示测试样例的数量。每个测试样例由两行组成。每一行包含两个小写拉丁字母,没有任何分隔符,表示图像中的一行像素。 输出格式:对于每个测试样例,输出一个整数——你最小操作次数,以使图像的 4 个像素具有相同的颜色。 **题目描述** You have an image file of size $2 \times 2$, consisting of 4 pixels. Each pixel can have one of 26 different colors, denoted by lowercase Latin letters. You want to recolor some of the pixels of the image so that all 4 pixels have the same color. In one move, you can choose no more than two pixels of the same color and paint them into some other color (if you choose two pixels, both should be painted into the same color). What is the minimum number of moves you have to make in order to fulfill your goal? **输入输出格式** 输入格式:第一行包含一个整数 $t$($1 \le t \le 1000$)——测试用例的数量。每个测试用例由两行组成。每行包含两个没有分隔符的小写拉丁字母,表示图像的一行像素。 输出格式:对于每个测试用例,打印一个整数——为了使图像的 4 个像素具有相同的颜色,你必须进行的最小移动次数。 **输入输出样例** 输入样例 #1: ``` 5 rb br cc wb aa aa ab cd yy xx ``` 输出样例 #1: ``` 1 2 0 3 1 ``` **说明** 让我们分析一下示例的测试用例。 在第一个测试用例中,你可以将左下角的像素和右上角的像素(它们具有相同的颜色)涂成颜色 r,这样所有像素都具有这种颜色。 在第二个测试用例中,两个动作就足够了: - 将两个顶部的像素,它们有相同的颜色 c,涂成颜色 b; - 将左下角的像素涂成颜色 b。 在第三个测试用例中,所有像素已经具有相同的颜色。 在第四个测试用例中,你可以保留任何一个像素的颜色不变,然后将其他三个像素涂成该像素的颜色,需要三步。 在第五个测试用例中,你可以将两个顶部像素涂成颜色 x。

加入题单

算法标签: