当前位置:网站首页>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.
边栏推荐
- Preg in PHP_ How to replace variable data
- Baidu voice synthesizes voice files and displays them on the website
- PMP考试“临门一脚”如何踢得漂亮?
- 高考之后,必然会出现以下四种情况:
- WinXP内核驱动调试
- sql 聚合函数有哪些
- Chinese and English instructions of trypsin
- IPC mechanism
- Why does Dell always refuse to push the ultra-thin commercial notebook to the extreme?
- C语言边界计算和不对称边界
猜你喜欢
随机推荐
創新藥二級市場審餅疲勞:三期臨床成功、產品獲批也不管用了
论文翻译 | RandLA-Net: Efficient Semantic Segmentation of Large-Scale Point Clouds
结合实操带你吃透Redis持久化
天书夜读笔记——内存分页机制
Cloud development technology summit · public welfare programming challenge [hot registration]!
Experiment 5 8254 timing / counter application experiment [microcomputer principle] [experiment]
放养但没有完全放养(春季每日一题 2)
脱氧核糖核酸酶I中英文说明书
全排列II[存在相同元素去重 + 标准回溯]
弹性蛋白酶中英文说明书
Some Modest Advice for Graduate Students - by Stephen C. Stearns, Ph.D.
门店无线音箱造假?索尼回应:产品预留了有线连接接口 复杂场景下可以使用
Unity C # e-learning (VI) -- FTP (II)
Fan benefits, JVM manual (including PDF)
多模态数据也能进行MAE?伯克利&谷歌提出M3AE,在图像和文本数据上进行MAE!最优掩蔽率可达75%,显著高于BERT的15%
Pbcms adding cyclic digital labels
动手学数据分析 数据建模和模型评估
JVM指令
PHP easywechat and applet realize long-term subscription message push
Fatigue liée à l'examen du marché secondaire des médicaments innovants: succès clinique de la phase III et approbation du produit









