cswork / OA打开练习工作台

IBMOA #36

Get Minimum Difference

估计简单可在线判题

考点(AI 标注)哈希计数字符串

For each pair of strings, you may replace any characters so that the two strings have the same character counts; find the minimum number of replacements. If the lengths differ, it is impossible; output -1.

输入格式

The first line contains n; each pair then takes two lines, and an empty string is given as an empty line. 1≤n≤100, lowercase letters; each string has length 0..10000, and each pair has total length 1..10000.

输出格式

Output n lines; line i is the minimum number for the i-th pair, or -1 if it is impossible.

样例 1

输入:

3
tea
ate
tea
toe
act
acts

输出:

0
1
-1

样例 2

输入:

1

a

输出:

-1

样例 3

输入:

1
aa
bb

输出:

2

样例说明

The examples output, line by line, 0, 1, -1; -1; and 2 respectively.