logo AlgoBeat OnlineJudge
登录 注册

#215723. [ICPC 2024 Jakarta R] Scrambled Scrabble

内存限制:1024 MiB 时间限制:1000 ms 标准输入输出
题目类型:VJudge(洛谷) 评测方式:VJudge
上传者: 匿名

题目描述

You are playing a word game using a standard set of uppercase English letters: A — Z. In this game, you can form vowels and consonants as follows.

  • The letters A, E, I, O, and U can only form a vowel.
  • The letter Y can form either a vowel or a consonant.
  • Each of the remaining letters other than A, E, I, O, U, and Y can only form a consonant.
  • The string NG can form a single consonant when concatenated together.

Denote a syllable as a concatenation of a consonant, a vowel, and a consonant in that order. A word is a concatenation of one or more syllables.

You are given a string and you want to create a word from it. You are allowed to delete zero or more letters from and rearrange the remaining letters to form the word. Find the length of the longest word that can be created, or determine if no words can be created.

输入格式

A single line consisting of a string ( ). The string consists of only uppercase English letters.

输出格式

If a word cannot be created, output 0. Otherwise, output a single integer representing the length of longest word that can be created.

样例

样例输入 1

ICPCJAKARTA

样例输出 1

9

样例输入 2

NGENG

样例输出 2

5

样例输入 3

YYY

样例输出 3

3

样例输入 4

DANGAN

样例输出 4

6

样例输入 5

AEIOUY

样例输出 5

0

数据范围与提示

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 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 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 is a word consisting of two syllables: DAN and GAN.