#P16278. 「MierOI R1」Present
「MierOI R1」Present
Problem Description
Two strings and , both of length , are called isomorphic if and only if:
- For any , if , then ; otherwise, .
Given two strings and , both of length . Among all strings that are isomorphic to , find the maximum number of pairs of identical characters at the same positions between and .
Input Format
This problem contains multiple test cases.
The first line of the input contains a positive integer , indicating the number of test cases.
Then, the test cases follow sequentially. For each test case:
- The first line contains a single positive integer .
- The second line contains a string of length .
- The third line contains a string of length .
Output Format
For each test case, output a single line containing an integer, representing the maximum number of pairs of identical characters at the same positions between and .
2
6
112233
221111
10
1234512345
1122334455
4
5
Hint
Explanation for Sample #1
For the first test case, we can have , and the number of pairs of identical characters at the same positions between it and is . It can be proven that this is the maximum number.
For the second test case, we can have , and the number of pairs of identical characters at the same positions between it and is . It can be proven that this is the maximum number.
Data Range
This problem uses bundled subtasks.
For all test cases, it is guaranteed that , , and both and consist only of numeric characters.
::cute-table{tuack}
| Subtask | Special Property | Score | |
|---|---|---|---|
| None | |||
| A | |||
| ^ | None |
- Special Property A: Both and consist only of $\texttt{0},\texttt{1},\texttt{2},\texttt{3},\texttt{4}$.