RiseOJ는 solved.ac와 제휴 관계가 없습니다. 티어 아이콘 © solved.ac. solved.ac
포럼
문제 ICPC00125

E. Evolution of Weasels

설명

A wild basilisk just appeared at your doorstep. You are not entirely sure what a basilisk is and you wonder whether it evolved from your favorite animal, the weasel. How can you find out whether basilisks evolved from weasels? Certainly, a good first step is to sequence both of their DNAs. Then you can try to check whether there is a sequence of possible mutations from the DNA of the weasel to the DNA of the basilisk. Your friend Ron is a talented alchemist and has studied DNA sequences in many of his experiments. He has found out that DNA strings consist of the letters A, B and C and that single mutations can only remove or add substrings (a substring is a contiguous sequence of characters). The substrings that can be removed or added by a mutation are AA, BB, CC, ABAB or BCBC. During a sequence of mutations a DNA string may even become empty. Ron has agreed to sequence the DNA of the weasel and the basilisk for you, but finding out whether there is a sequence of possible mutations that leads from one to the other is too difficult for him, so you have to do it on your own.

제약
입력 형식

Each test contains multiple test cases. The first line contains an integer \(t\) (\(1 \le t \le 100\)) — the number of test cases. The descriptions of the \(t\) test cases follow. The first line of each test case contains a string \(u\) (1 ≤|\(u\)| ≤200) — the DNA of the weasel. The second line of each test case contains a string \(v\) (1 ≤|\(v\)| ≤200) — the DNA of the basilisk. The values |\(u\)|, |\(v\)| denote the lengths of the strings \(u\) and \(v\). It is guaranteed that both strings \(u\) and \(v\) consist of the letters A, B and C.

출력 형식

For each test case, print YES if there is a sequence of mutations to get from \(u\) to \(v\) and NO otherwise. Problem E: Evolution of Weasels SWERC \(2021-2022\)

예제 1
입력
8
A
B
B
C
C
A
AA
BB
BB
CC
CC
AA
ABAB
BCBC
ABC
CBA
출력
NO
NO
NO
YES
YES
YES
YES
NO
문제 정보

생성자가 기록되지 않았습니다.

출처 ICPC SWERC 2021

평가 및 의견

E. Evolution of Weasels

개요
출제자 난이도 Unrated 레이팅 미적용 의견 0 / 50 공개 집계 (커뮤니티 난이도, 주요 주제, 품질)는 의견이 충분히 모이면 공개됩니다.

Log in to rate problems.

개별 의견

아직 의견이 없습니다. 자격이 된다면 위 양식에서 가장 먼저 평가해 보세요.

풀이 제출

E. Evolution of Weasels

게스트로 둘러보고 있습니다. 로그인하면 풀이를 제출하고 진행 상황을 확인할 수 있습니다. 로그인하고 제출하기
공개
C++20 Tab 들여쓰기 · Ctrl+/ 주석 토글 · Enter 자동 들여쓰기
1 1 1 0 공백: 4 · UTF-8