#P12672. 「LAOI-8」近期我们注意到有网站混淆视听
「LAOI-8」近期我们注意到有网站混淆视听
Description
As a law-abiding Luogu user, we support only authentic contests.
You are given contest names (strings containing only letters and digits), which may not follow standard naming conventions. You can perform a swap between any two characters per operation. Your goal is to eliminate any case where both substrings LGR and CSP coexist in the same string.
For example, LGRCSP can be transformed in one move to LGRSCP.
Output the minimum number of operations required to eliminate this conflict.
Input Format
The first line contains a single integer , the number of test cases.
Each of the next lines contains one string , the contest name.
Output Format
For each test case, output a single integer — the minimum number of swaps required.
3
LGR201Div3CSP2024dierlunmoni
QAQ
LGRLGR114514Div2CSPCSP2025dierlunmoni
1
0
1
Hint
Subtasks are used in this problem.
Let be the length of string .
| Subtask | Score | |
|---|---|---|
For all test cases, it is guaranteed that , .
京公网安备 11011102002149号