A1014 | Uddered but not Herd--Gold
来源USACO
时间限制1s
内存限制128MB
通过 / 提交0/0
题目描述
A little known fact about cows is that they have their own version of the
alphabet, the "cowphabet". It consists of the 26 letters 'a' through 'z', but
when a cow speaks the cowphabet, she lists these letters in a specific
ordering that might be different from the order 'abcdefghijklmnopqrstuvwxyz'
we are used to hearing.
To pass the time, Bessie's cousin Mildred has been humming the cowphabet over
and over again, and Farmer Nhoj is curious how many times she's hummed it.
Given a lowercase string of letters that Farmer Nhoj has heard Mildred say,
compute the minimum number of times Mildred must have hummed the entire
cowphabet in order for Farmer Nhoj to have heard the given string. Farmer Nhoj
isn't always paying attention to what Mildred hums, and so he might have
missed some of the letters that Mildred has hummed. The string you are told
consists of just the letters that he remembers hearing.
Note: the time limit per test case on this problem is twice the default.
alphabet, the "cowphabet". It consists of the 26 letters 'a' through 'z', but
when a cow speaks the cowphabet, she lists these letters in a specific
ordering that might be different from the order 'abcdefghijklmnopqrstuvwxyz'
we are used to hearing.
To pass the time, Bessie's cousin Mildred has been humming the cowphabet over
and over again, and Farmer Nhoj is curious how many times she's hummed it.
Given a lowercase string of letters that Farmer Nhoj has heard Mildred say,
compute the minimum number of times Mildred must have hummed the entire
cowphabet in order for Farmer Nhoj to have heard the given string. Farmer Nhoj
isn't always paying attention to what Mildred hums, and so he might have
missed some of the letters that Mildred has hummed. The string you are told
consists of just the letters that he remembers hearing.
Note: the time limit per test case on this problem is twice the default.
输入格式
The only line of input contains the string of lowercase letters that Farmer
Nhoj heard Mildred say. This string has length at least $1$ and at most
$10^5$.
Nhoj heard Mildred say. This string has length at least $1$ and at most
$10^5$.
输出格式
Print the minimum number of times Mildred must have hummed the entire
cowphabet.
cowphabet.
输入输出样例
输入 #1
mildredree
输出 #1
3 Mildred must have hummed the cowphabet at least three times. It is possible
for Mildred to have only hummed the cowphabet three times if the cowphabet
starts with "mildre" and Farmer Nhoj heard the letters in uppercase as denoted
below.
MILDREabcfghjknopqstuvwxyz
milDREabcfghjknopqstuvwxyz
mildrEabcfghjknopqstuvwxyz
starts with "mildre" and Farmer Nhoj heard the letters in uppercase as denoted
below.
MILDREabcfghjknopqstuvwxyz
milDREabcfghjknopqstuvwxyz
mildrEabcfghjknopqstuvwxyz
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted