P16278 「MierOI R1」Present
Description
Two strings $a$ and $b$, both of length $m$, are called **isomorphic** if and only if:
- For any $1 \le i,j \le m$, if $a_i=a_j$, then $b_i=b_j$; otherwise, $b_i \ne b_j$.
Given two strings $s$ and $t$, both of length $n$. Among all strings $s'$ that are isomorphic to $s$, find the maximum number of pairs of **identical characters** at the **same positions** between $s'$ and $t$.
Input Format
**This problem contains multiple test cases.**
The first line of the input contains a positive integer $T$, indicating the number of test cases.
Then, the $T$ test cases follow sequentially. For each test case:
- The first line contains a single positive integer $n$.
- The second line contains a string $s$ of length $n$.
- The third line contains a string $t$ of length $n$.
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 $s'$ and $t$.
Explanation/Hint
#### Explanation for Sample #1
For the first test case, we can have $s'=\texttt{221133}$, and the number of pairs of identical characters at the same positions between it and $t=\texttt{221111}$ is $4$. It can be proven that this is the maximum number.
For the second test case, we can have $s'=\texttt{1425314253}$, and the number of pairs of identical characters at the same positions between it and $t=\texttt{1122334455}$ is $5$. 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 $1 \le T \le 5$, $1 \le n \le 10^5$, and both $s$ and $t$ consist only of numeric characters.
::cute-table{tuack}
| Subtask | $n \le$ | Special Property | Score |
|:-:|:-:|:-:|:-:|
| $1$ | $5$ | None | $30$ |
| $2$ | $10^5$ | A | $30$ |
| $3$ | ^ | None | $40$ |
- Special Property A: Both $s$ and $t$ consist only of $\texttt{0},\texttt{1},\texttt{2},\texttt{3},\texttt{4}$.