当前位置:网站首页>放养但没有完全放养(春季每日一题 2)
放养但没有完全放养(春季每日一题 2)
2022-06-24 21:39:00 【51CTO】
一个鲜为人知的事实是,奶牛拥有自己的文字:「牛文」。
牛文由 个字母
a 到 z 组成,但是当奶牛说牛文时,可能与我们所熟悉的 abcdefghijklmnopqrstuvwxyz 不同,她会按某种特定的顺序排列字母。
为了打发时间,奶牛 Bessie 在反复哼唱牛文字母歌,而 Farmer John 好奇她唱了多少遍。
给定一个小写字母组成的字符串,为 Farmer John 听到 Bessie 唱的字母,计算 Bessie 至少唱了几遍完整的牛文字母歌,使得 Farmer John 能够听到给定的字符串。
Farmer John 并不始终注意 Bessie 所唱的内容,所以他可能会漏听 Bessie 唱过的一些字母。
给定的字符串仅包含他记得他所听到的字母。
输入格式
输入的第一行包含 个小写字母,为
a到z的牛文字母表顺序。
下一行包含一个小写字母组成的字符串,为 Farmer John 听到 Bessie 唱的字母。
输出格式
输出 Bessie 所唱的完整的牛文字母歌的最小次数。
数据范围
字符串的长度不小于 且不大于
。
输入样例:
输出样例:
样例解释
在这个样例中,牛文字母表与日常的字母表的排列一致。
Bessie 至少唱了三遍牛文字母歌。
有可能 Bessie 只唱了三遍牛文字母歌,而 Farmer John 听到了以下被标记为大写的字母。
using
namespace
std;
const
int
N
=
1010;
char
a[
30],
s[
N];
int
pos[
30];
int
main(){
scanf(
"%s",
a);
for(
int
i
=
0;
i
<
26;
i
++)
pos[
a[
i]
-
'a']
=
i;
scanf(
"%s",
s);
int
n
=
strlen(
s);
int
pre
=
30;
int
res
=
0;
for(
int
i
=
0;
i
<
n;
i
++){
int
x
=
pos[
s[
i]
-
'a'];
if(
x
<=
pre)
res
++;
pre
=
x;
}
cout
<<
res
<<
endl;
return
0;
}
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
- 9.
- 10.
- 11.
- 12.
- 13.
- 14.
- 15.
- 16.
- 17.
- 18.
- 19.
- 20.
- 21.
- 22.
- 23.
- 24.
- 25.
- 26.
- 27.
- 28.
- 29.
- 30.
- 31.
- 32.
边栏推荐
- Use redis' sorted set to make weekly hot Reviews
- Ideas and examples of divide and conquer
- ICML2022 | 用神经控制微分方程建立反事实结果的连续时间模型
- (CVPR 2020) Learning Object Bounding Boxes for 3D Instance Segmentation on Point Clouds
- Combined with practice, you will understand redis persistence
- Tianshu night reading notes -- disassembly engine xde32
- Google browser console F12 how to set the Chinese / English switching method, we must see the last!!!
- Abnova 5-methylcytosine polyclonal antibody
- Linux64Bit下安装MySQL5.6-不能修改root密码
- Deoxyribonuclease I instructions in Chinese and English
猜你喜欢

Tianshu night reading notes -- memory paging mechanism
![Full arrangement ii[duplicate removal of the same elements + standard backtracking]](/img/d3/93ddb49e580be60be4f056f141b782.png)
Full arrangement ii[duplicate removal of the same elements + standard backtracking]

动手学数据分析 数据建模和模型评估

"One good programmer is worth five ordinary programmers!"

js数组对象转对象

【LeetCode】11、盛最多水的容器

Multi modal data can also be Mae? Berkeley & Google proposed m3ae to conduct Mae on image and text data! The optimal masking rate can reach 75%, significantly higher than 15% of Bert

TC对象结构和简称

Boutique enterprise class powerbi application pipeline deployment

Bi-sql - join
随机推荐
Reading notes at night -- deep into virtual function
Some Modest Advice for Graduate Students - by Stephen C. Stearns, Ph.D.
Matlab rounding
uni-app集成极光推送插件后真机调试提示“当前运行的基座不包含原生插件[JG-JPush]...”问题的解决办法
js数组对象转对象
弹性蛋白酶中英文说明书
Bi SQL constraints
Day 04 - file IO
天书夜读笔记——深入虚函数virtual
Excel Chinese character to pinyin "suggestions collection"
Combined with practice, you will understand redis persistence
IPC机制
Preg in PHP_ How to replace variable data
第04天-文件IO
【LeetCode】11、盛最多水的容器
After the college entrance examination, the following four situations will inevitably occur:
leetcode:2104. 子数组范围和
1. package your own scaffold 2 Create code module
广发期货安全吗?开户需要什么东西?
Tencent cloud wecity Hello 2022!