当前位置:网站首页>Stocking but not completely stocking (daily question 2 in spring)
Stocking but not completely stocking (daily question 2 in spring)
2022-06-25 01:50:00 【51CTO】
A little-known fact is , Cows have their own words :「 Niu Wen 」.
Niu Wenyou Letters
a To z form , But when the cow says Niu Wen , May be familiar to us abcdefghijklmnopqrstuvwxyz Different , She will arrange the letters in a certain order .
To pass the time , cow Bessie Humming the cow alphabet song repeatedly , and Farmer John Wonder how many times she sang .
Given a string of lowercase letters , by Farmer John hear Bessie Sing the letters , Calculation Bessie At least a few times I sang the complete song of the cow alphabet , bring Farmer John Can hear a given string .
Farmer John Not always pay attention to Bessie What you sing , So he may miss listening Bessie Some of the letters sung .
The given string contains only the letters he remembers he hears .
Input format
The first line of input contains Lowercase letters , by
a To z The order of the Niu alphabet .
The next line contains a string of lowercase letters , by Farmer John hear Bessie Sing the letters .
Output format
Output Bessie The minimum number of complete niuwen alphabet songs sung .
Data range
The length of the string is not less than And not more than
.
sample input :
sample output :
Sample explanation
In this example , The Niu alphabet is in line with the daily alphabet .
Bessie At least three times .
There may be Bessie I only sang the song of the cow alphabet three times , and Farmer John I heard the following capitalized letters .
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.
边栏推荐
猜你喜欢

多模态数据也能进行MAE?伯克利&谷歌提出M3AE,在图像和文本数据上进行MAE!最优掩蔽率可达75%,显著高于BERT的15%

"One good programmer is worth five ordinary programmers!"

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

Bi SQL constraints

DataEase模板市场正式发布

Day 04 - file IO

Install mysql5.6 under linux64bit - the root password cannot be modified
![Experiment 5 8254 timing / counter application experiment [microcomputer principle] [experiment]](/img/e2/7da59a566e4ccb8e43f2a64c0420e7.png)
Experiment 5 8254 timing / counter application experiment [microcomputer principle] [experiment]
![搜索二维矩阵[二分巧用 + 记录不同于插入二分的解法]](/img/c9/afc03afd477bbfdd3c0dc54bacfd2d.png)
搜索二维矩阵[二分巧用 + 记录不同于插入二分的解法]

Abnova丨CSV 磁珠中英文说明
随机推荐
论文翻译 | RandLA-Net: Efficient Semantic Segmentation of Large-Scale Point Clouds
高考之后,必然会出现以下四种情况:
Transformers 库的基本使用
excel 汉字转拼音「建议收藏」
write a number of lines to a new file in vim
Abnova 5-methylcytosine polyclonal antibody
实验5 8254定时/计数器应用实验【微机原理】【实验】
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
JVM指令
Baidu voice synthesizes voice files and displays them on the website
String common methods
在两个有序数组中找到整体第K小的数可以做到O(log(Min(M,N)))
国内炒股开户正规安全的具体名单
php easywechat 和 小程序 实现 长久订阅消息推送
Cloud development technology summit · public welfare programming challenge [hot registration]!
Redis basic commands and types
An Chaoyun: "one cloud with multiple cores" supports the implementation of the national information innovation government cloud
Listen to the markdown file and hot update next JS page
明日考试 最后一天如何备考?二造考点攻略全整理
AUTOCAD——两种延伸方式