Skip to content
neoideasblog

neoideasblog

  • Home
    • Privacy Policy
    • About Us
    • Contact Us
    • Terms
  • Trivia
  • Results
  • Admit Cards
  • Sitemaps
  • Toggle search form

I love AAAB solution codeforces

Posted on April 23, 2022 By Admin No Comments on I love AAAB solution codeforces

I love AAAB solution codeforces

 

Let’s call a string good if its length is at least 22 and all of its characters are AA except for the last character which is BB. The good strings are AB,AAB,AAAB,…AB,AAB,AAAB,…. Note that BB is not a good string.

You are given an initially empty string s1s1.

You can perform the following operation any number of times:

  • Choose any position of s1s1 and insert some good string in that position.

Given a string s2s2, can we turn s1s1 into s2s2 after some number of operations?

ALSO READ:-   Controlled Inflation solution codejam
Input

Each test contains multiple test cases. The first line contains a single integer tt (1≤t≤1041≤t≤104) — the number of test cases. The description of the test cases follows.

The first line of each test case contains a single string s2s2 (1≤|s2|≤2⋅1051≤|s2|≤2⋅105).

It is guaranteed that s2s2 consists of only the characters AA and BB.

It is guaranteed that the sum of |s2||s2| over all test cases does not exceed 2⋅1052⋅105.

ALSO READ:-   Cyclic Rotation solution codeforces
Output

For each test case, print “YES” (without quotes) if we can turn s1s1 into s2s2 after some number of operations, and “NO” (without quotes) otherwise.

You can output “YES” and “NO” in any case (for example, strings “yEs“, “yes” and “Yes” will be recognized as a positive response).

Example
input

Copy
4
AABAB
ABB
AAAAAAAAB
A
output

Copy
YES
NO
YES
NO
Note

In the first test case, we transform s1s1 as such: ∅→AAB→AABAB∅→AAB→AABAB.

ALSO READ:-   PermutationForces solution codeforces

In the third test case, we transform s1s1 as such: ∅→AAAAAAAAB∅→AAAAAAAAB.

In the second and fourth test case, it can be shown that it is impossible to turn s1s1 into s2s2.

ANSWER

“Click Here“

Admin

I am the Founder and the creator of the blog neoideasblog.com where we share latest trivia questions and answers on a daily basis.

Results

Post navigation

Previous Post: Log Chopping solution codeforces
Next Post: Unequal Array solution codeforces

Related Posts

Array Balancing solution codeforces Results
uptet result 2022, Download Link @updeled.gov.in Results
Checker for Array Shuffling solution codeforces Results
Unequal Array solution codeforces Results
Pancake Deque solution codejam Results
Array Shuffling solution codeforces Results

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Archives

  • July 2022
  • June 2022
  • May 2022
  • April 2022

Categories

  • Admit Cards
  • Results
  • Trivia

Disclaimer

Disclaimer: Our website name Neoideasblog.com. we are just a news portal that covers various updates and stories.

Copyright © 2022 neoideasblog.

Powered by PressBook Grid Blogs theme