| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 1 초 | 2048 MB | 93 | 49 | 42 | 66.667% |
Busy Beaver has a string $A$ made up of characters P and N. He can perform two types of operations on $A$:
P and replace it with NP.NP and replace it with P.Busy Beaver has a target string $B$. Determine if he can turn $A$ into $B$ after some number of operations.
1A substring of length $k$ is a contiguous sequence of $k$ adjacent characters of a string.
The first line contains a single integer $T$ (1ドル \leq T \leq 10^4$) --- the number of test cases.
The only line of each test case contains the strings $A$ and $B$ (1ドル \leq |A|, |B| \leq 10^5$), consisting of characters P and N.
The sum of $|A|+|B|$ across all test cases does not exceed 2ドル \cdot 10^5$.
For each test case, output YES if Busy Beaver can turn $A$ into $B$ using the operations above, and NO otherwise.
7 P NP PNPN NPPN PP NP NPN PPNP PNPP PPNNNNNNNNNNNNNNNNNNP PPNNPPNNPP NNPPNNPPNN NPNNNNNPN PPPN
YES YES NO NO YES NO NO
In the first test case, we can perform one operation to turn P into NP.
In the second test case, we can do two operations: PNPN $\to$ PPN and then PPN $\to$ NPPN.
In the third test case, we can show that it is not possible to turn PP into NP using any number of operations.
University > MIT > M(IT)^2 > M(IT)^2 Winter 2025-26 Tournament > Beginner Round 2번