cswork / OA打开练习工作台

AmazonOA #140

Equal Products

估计简单可在线判题

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

Each operation picks two distinct lowercase letters and swaps all of their occurrences in the whole string; one of the letters may currently be absent. For each pair of equal-length strings, decide whether the transformation is possible and output 1 or 0.

输入格式

The first line contains n (1..100000), followed by n lines, each with two non-empty lowercase strings of equal length. Each string has length ≤200000, and the total length of all strings is ≤500000.

输出格式

Output n values, each 0 or 1, in input order.

样例 1

输入:

1
abba adda

输出:

1

样例 2

输入:

1
azzel apple

输出:

1

样例 3

输入:

2
ab aa
aba xyx

输出:

0 1

样例说明

Example 1: swapping b and d is enough, so output 1. Example 2: swap z and p, then swap e and l, so output 1. Example 3: the two characters of ab cannot both become a, so output 0; aba can map to xyx, so output 1.