generated from OPCODE-Open-Spring-Fest/template
-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6884cdd
commit 54ec175
Showing
3 changed files
with
47 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
In the realm of beautiful strings, a string is deemed beautiful if it satisfies two crucial conditions: | ||
|
||
1. Every character within the string must be either A, B, or C. | ||
2. No two adjacent characters are identical. | ||
|
||
For instance, AB and BCAC qualify as beautiful strings, whereas BB and CBAAC fall short of the beauty standard. | ||
|
||
You're entrusted with a beautiful string s . Your task: to morph it into the lexicographically smallest possible string while preserving its beauty. To achieve this, you're allowed to perform a single operation repeatedly: | ||
|
||
Operation: | ||
- Swap two adjacent characters in s , ensuring that the string remains beautiful even after the swap. | ||
|
||
You're presented with t test cases, each requiring its own solution. | ||
|
||
Input: | ||
- Each test case segment commences with a line containing a single integer t ( 1 ≤ t ≤ 10^5 ) denoting the number of sets of input data. | ||
- Following this are descriptions of the test cases. | ||
- The first line of each test case holds the beautiful string s , where |s| represents its length ( 1 ≤ |s| ≤ 10^6 ). | ||
|
||
Output: | ||
- Your output should consist of t lines. | ||
- Each line should contain the lexicographically smallest string that s can transform into for the corresponding test case. | ||
|
||
Feel free to swap and shuffle your way through the test cases, crafting the most aesthetically pleasing strings! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
Example | ||
|
||
Input | ||
8 | ||
CAB | ||
ACBCB | ||
B | ||
AC | ||
BACBA | ||
BABABA | ||
ABCBCAC | ||
CBABACABCBABABC | ||
|
||
Output | ||
ABC | ||
ABCBC | ||
B | ||
AC | ||
ABABC | ||
BABABA | ||
ABCACBC | ||
ABABACBCACBCBAB |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
//write your code here |