#P10653. [ROI 2017] 存储器 (Day 2)
[ROI 2017] 存储器 (Day 2)
Problem Description
Given a string of length , each character is either + or -.
Define a segment as a substring of that satisfies the following three conditions:
- or .
- or .
- .
Define one transformation as:
- Choose two adjacent segments of with different lengths, and change every character in the shorter segment to its opposite character (
+becomes-,-becomes+).
Now there are queries. For each query, you are given two strings and that contain only + and - and have the same length. Please determine whether can be transformed into through several transformations.
Input Format
The first line contains an integer , the number of queries.
The next lines each contain two strings , with the meaning as described above.
Output Format
For each query, output one line containing Yes or No, indicating whether the requirement can be satisfied.
3
++- +++
++-- ++++
++-+--+- ++++++++
Yes
No
Yes
3
++-+-- ++----
++-+-- +++---
-++- -++-
Yes
No
Yes
Hint
Constraints
Note: This problem only provides partial testdata. For the full testdata, please go to LOJ P2770 for judging.
Let .
| Subtask ID | Score | Special Property | |
|---|---|---|---|
There is no - in |
|||
| None | |||
Translated by ChatGPT 5