String Split

면접 대비

시간 제한1초메모리 제한1024 MB

요약
문자열 s에서 홀수 번째 문자 전체 또는 짝수 번째 문자 전체를 반복해서 지울 수 있을 때, s를 t로 만들 수 있는지 판정한다.
난이도

보통10점 중 5점

유형
문자열, 동적 계획법, 구현
정답자
아직 제출이 없습니다

문제

You are given two strings ss and tt. In one operation, you can delete all the odd-indexed characters from ss or all the even-indexed characters from ss.

For example, if you perform an operation on the string abcdefg, you could choose to turn it into aceg or bdf.

After performing any number of operations on ss (including zero), is it possible for ss to equal tt?

입력

The first line of the input contains a single integer tt (1≤t≤1041 \le t \le 10^4) --- the number of test cases. The description of the test cases follows.

The first line of each test case contains a string ss (1≤∣s∣≤2⋅1051 \le |s| \le 2\cdot 10^5) of lowercase letters --- the starting string, as described above.

The second line of each test case contains a string tt (1≤∣t∣≤2⋅1051 \le |t| \le 2\cdot 10^5) of lowercase letters --- the desired ending string, as described above.

It is guaranteed that the sum of ∣s∣|s| over all test cases does not exceed 2⋅1052\cdot 10^5. Similarly, the sum of ∣t∣|t| over all test cases does not exceed 2⋅1052\cdot 10^5.

출력

For each test case, print "YES" if it is possible to make all ss equal to tt after any number of operations, and "NO" otherwise.

You can output the answer in any case (upper or lower). For example, the strings "yEs", "yes", "Yes", and "YES" will be recognized as positive responses.

힌트

In the first test case, by removing all even-indexed characters of ss, we obtain s=thomass = thomas, so we have s=ts = t.

In the second test case, the length of ss is less than the length of tt, and if we perform any operations, the length of ss will only decrease. Therefore, ss can never equal tt.

In the third test case, we have s=ts = t even before performing any operations.

예제1

  1. 예제 1

    입력
    6
    tjhdoumraise
    thomas
    nick
    james
    baccba
    baccba
    abcdefg
    cde
    abcdabcd
    aa
    abcdabcd
    bc
    
    예상 출력
    YES
    NO
    YES
    NO
    YES
    NO