QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 2048 MB Total points: 100

#10571. Scrambled Scrabble

الإحصائيات

你正在使用一套标准的 26 个大写英文字母(A - Z)进行文字游戏。在这个游戏中,你可以按照以下规则构成元音和辅音:

  • 字母 A、E、I、O 和 U 只能构成元音。
  • 字母 Y 既可以构成元音,也可以构成辅音。
  • 除 A、E、I、O、U 和 Y 以外的其余字母只能构成辅音。
  • 字符串 NG 连接在一起时可以构成一个单独的辅音。

我们将“音节”定义为按顺序连接的一个辅音、一个元音和一个辅音。一个“单词”是由一个或多个音节连接而成的。

给定一个字符串 $S$,你想要从中创建一个单词。你可以删除 $S$ 中的零个或多个字母,并重新排列剩余的字母来组成单词。请找出可以创建的最长单词的长度,如果无法创建任何单词,则输出 0。

输入格式

一行,包含一个字符串 $S$ ($1 \le |S| \le 5000$)。字符串 $S$ 仅由大写英文字母组成。

输出格式

如果无法创建单词,输出 0。否则,输出一个整数,表示可以创建的最长单词的长度。

样例

输入 1

ICPCJAKARTA

输出 1

9

说明 1

一个可能的最长单词是 JAKCARTAP,由音节 JAK、CAR 和 TAP 组成。

输入 2

NGENG

输出 2

5

说明 2

整个字符串 $S$ 是一个单词,由一个音节组成,该音节由辅音 NG、元音 E 和辅音 NG 连接而成。

输入 3

YYY

输出 3

3

说明 3

整个字符串 $S$ 是一个单词,由一个音节组成,该音节由辅音 Y、元音 Y 和辅音 Y 连接而成。

输入 4

DANGAN

输出 4

6

说明 4

整个字符串 $S$ 是一个单词,由两个音节组成:DAN 和 GAN。

输入 5

AEIOUY

输出 5

0

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.