CF1921B.Arranging Cats

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

In order to test the hypothesis about the cats, the scientists must arrange the cats in the boxes in a specific way. Of course, they would like to test the hypothesis and publish a sensational article as quickly as possible, because they are too engrossed in the next hypothesis about the phone's battery charge.

Scientists have nn boxes in which cats may or may not sit. Let the current state of the boxes be denoted by the sequence b1,,bnb_1, \dots, b_n : bi=1b_i = 1 if there is a cat in box number ii , and bi=0b_i = 0 otherwise.

Fortunately, the unlimited production of cats has already been established, so in one day, the scientists can perform one of the following operations:

  • Take a new cat and place it in a box (for some ii such that bi=0b_i = 0 , assign bi=1b_i = 1 ).
  • Remove a cat from a box and send it into retirement (for some ii such that bi=1b_i = 1 , assign bi=0b_i = 0 ).
  • Move a cat from one box to another (for some i,ji, j such that bi=1,bj=0b_i = 1, b_j = 0 , assign bi=0,bj=1b_i = 0, b_j = 1 ).

It has also been found that some boxes were immediately filled with cats. Therefore, the scientists know the initial position of the cats in the boxes s1,,sns_1, \dots, s_n and the desired position f1,,fnf_1, \dots, f_n .

Due to the large amount of paperwork, the scientists do not have time to solve this problem. Help them for the sake of science and indicate the minimum number of days required to test the hypothesis.

输入格式

Each test consists of several test cases. The first line contains a single integer tt ( 1t1041 \le t \le 10^4 ) — the number of test cases. This is followed by descriptions of the test cases.

Each test case consists of three lines.

The first line of each test case contains a single integer nn ( 1n1051 \le n \le 10^5 ) — the number of boxes.

The second line of each test case contains a string ss of nn characters, where the ii -th character is '1' if there is a cat in the ii -th box and '0' otherwise.

The third line of each test case contains a string ff of nn characters, where the ii -th character is '1' if there should be a cat in the ii -th box and '0' otherwise.

It is guaranteed that in a test the sum of nn over all test cases does not exceed 10510^5 .

输出格式

For each test case, output a single integer on a separate line — the minimum number of operations required to obtain the desired position from the initial position. It can be shown that a solution always exists.

输入输出样例

  • 输入#1

    6
    5
    10010
    00001
    1
    1
    1
    3
    000
    111
    4
    0101
    1010
    3
    100
    101
    8
    10011001
    11111110

    输出#1

    2
    0
    3
    2
    1
    4

说明/提示

In the first test case, you can first move the cat from the first box to the fifth, and then remove the cat from the fourth box.

In the second test case, there is nothing to do — the only cat is already sitting in the correct box.

In the third test case of input data, it takes three days to place a cat in each box.

首页