双下标法找最长公共子序列(不能删除字符)

#include<bits/stdc++.h>
using namespace std;
const int maxn=;
string s;
string t;
int main () {
cin>>s>>t;
int maxLength=;
int st,ed;
for (int i=;i<s.length();i++) {
st=i;
ed=;
while (st<s.length()&&ed<s.length()) {
if (s[ed]==t[st]) st++;
ed++;
}
maxLength=max(maxLength,st-i);
}
printf ("%d",s.length()-maxLength);
return ;
}

PAT T1015 Letter-moving Gam的更多相关文章

  1. PAT A1153 Decode Registration Card of PAT (25 分)——多种情况排序

    A registration card number of PAT consists of 4 parts: the 1st letter represents the test level, nam ...

  2. PAT 1032 Sharing[hash][链表][一般上]

    1032 Sharing (25)(25 分) To store English words, one method is to use linked lists and store a word l ...

  3. 1153 Decode Registration Card of PAT (25 分)

    A registration card number of PAT consists of 4 parts: the 1st letter represents the test level, nam ...

  4. PAT_A1153#Decode Registration Card of PAT

    Source: PAT A1153 Decode Registration Card of PAT (25 分) Description: A registration card number of ...

  5. PAT(B) 1057 数零壹(Java)字符串

    题目链接:1057 数零壹 (20 point(s)) 题目描述 给定一串长度不超过 10​5​​ 的字符串,本题要求你将其中所有英文字母的序号(字母 a-z 对应序号 1-26,不分大小写)相加,得 ...

  6. PAT Advanced 1153 Decode Registration Card of PAT (25 分)

    A registration card number of PAT consists of 4 parts: the 1st letter represents the test level, nam ...

  7. PAT甲级【2019年3月考题】——A1157 Anniversary【25】

    Zhejiang University is about to celebrate her 122th anniversary in 2019. To prepare for the celebrat ...

  8. PAT甲级——A1153 DecodeRegistrationCardofPAT【25】

    A registration card number of PAT consists of 4 parts: the 1st letter represents the test level, nam ...

  9. PAT甲级——A1032 Sharing

    To store English words, one method is to use linked lists and store a word letter by letter. To save ...

随机推荐

  1. 507,介绍一下标准的css盒子模型?低版本ie的盒子模型有什么不同的?

    有两种,IE盒子模型,另外是W3C盒子模型: 盒模型都包括:内容(content),填充(padding),边界(margin),边框(border): 区别:IE的content部分吧border和 ...

  2. CentOS7安装jdk教程

    引言Oracle JDK和OpenJDK的简单介绍Oracle JDK是基于Java标准版规范实现的,以二进制产品的形式发布.它支持多种操作系统,如Windows,Linux,Solaris,MacO ...

  3. Windows设置Tomcat的管理员的用户和密码

    我们首先打开Tomcat的配置文件,具体如下:(conf目录下的tomcat-users.xml) 删除原有的<tomcat-users>,加入如下代码 <tomcat-users& ...

  4. php-cp(php连接池)扩展的安装

    今天看到php有连接池的扩展,不管效果怎么样,都值得一试,这样才会有突破. 先从guthub上搜索源码:[ https://github.com/swoole/php-cp ] 通过命令clone到自 ...

  5. Bugku-CTF加密篇之凯撒部长的奖励(就在8月,超师傅出色地完成了上级的特遣任务,凯撒部长准备给超师傅一份特殊的奖励.......)

    凯撒部长的奖励 就在8月,超师傅出色地完成了上级的特遣任务,凯撒部长准备给超师傅一份特殊的奖励,兴高采烈的超师傅却只收到一长串莫名的密文,超师傅看到英语字串便满脸黑线,帮他拿到这份价值不菲的奖励吧. ...

  6. plutosdr初步

    关于最近新出的pluto sdr ,一款较新的sdr,可以通过破解将ad9363改成ad9361,提升频率范围,但是据说没有办法改变带宽. 可以通过补丁方式使用某款软件来进行收听fm

  7. 【C语言】将输入的10个整数逆序输出

    代码1: #include <stdio.h> int main() { ], b[]; int i,j; printf("请输入10个整数:\n"); ; i < ...

  8. 关于 checkbox 的一些操作

    获取checkbox选中的状态 $("#checkbox").is(":checked"); 设置 checkbox 的状态 $("#checkbox ...

  9. JPA中实现双向多对多的关联关系(附代码下载)

    场景 JPA入门简介与搭建HelloWorld(附代码下载): https://blog.csdn.net/BADAO_LIUMANG_QIZHI/article/details/103473937 ...

  10. Sqlmap 工具用法详解

    Sqlmap 工具用法详解                                 sqlmap是一款自动化的sql注入工具.     1.主要功能:扫描.发现.利用给定的url的sql注入漏 ...