CF2045A Scrambled Scrabble
题目描述
你正在参与一个字母游戏,该游戏使用标准的26个大写英文字母A到Z。在这个游戏中,元音和辅音的构成规则如下:
- A, E, I, O, U 是元音。
- Y 可以作为元音或辅音。
- 除A, E, I, O, U和Y之外的其他字母只作为辅音。
- 子串NG可以作为一个整体看作辅音。
一个音节被定义为依次连接的辅音、元音和辅音。一个由一个或多个音节组成的字符串被定义为一个单词。
现在,给你一个字符串 $S$,你需要利用这个字符串中的字母构建一个单词。你可以从 $S$ 中删除任意数量的字母,并重新排列剩下的字母。请计算出可以构建的最长单词的长度,若无法构建任何单词,则返回0。
输入格式
输入为一行,包含一个仅由大写英文字母组成的字符串 $S$ ( $1 \leq |S| \leq 5000 $ )。
输出格式
如果不能构建任何单词,输出0。否则,输出一个整数,表示可以构建的最长单词的长度。
## 例子解释
- 示例1:一个可能的最长单词是JAKCARTAP,由音节JAK、CAR和TAP组成。
- 示例2:整个字符串$S$可看作一个单词,包含一个音节,这个音节由辅音NG、元音E和辅音NG构成。
- 示例3:整个字符串$S$是一个单词,由音节Y、Y、Y构成,分别作为辅音、元音和辅音。
- 示例4:整个字符串$S$为一个单词,包括音节DAN和GAN。
**本翻译由 AI 自动生成**
说明/提示
Explanation for the sample input/output #1
A possible longest word is JAKCARTAP, consisting of the syllables JAK, CAR, and TAP.
Explanation for the sample input/output #2
The whole string $ S $ is a word consisting of one syllable which is the concatenation of the consonant NG, the vowel E, and the consonant NG.
Explanation for the sample input/output #3
The whole string $ S $ is a word consisting of one syllable which is the concatenation of the consonant Y, the vowel Y, and the consonant Y.
Explanation for the sample input/output #4
The whole string $ S $ is a word consisting of two syllables: DAN and GAN.