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

#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. 吴裕雄 python 机器学习——数据预处理过滤式特征选取SelectPercentile模型

    from sklearn.feature_selection import SelectPercentile,f_classif #数据预处理过滤式特征选取SelectPercentile模型 def ...

  2. windows CMakeLists.txt

    在windows下写好CMakeLists.txt,然后配合cmake-gui使用. CMakeLists.txt写的不够好,后期优化,以下仅供参考: # set(OpenCV_DIR D:/Prog ...

  3. JavaScript - 获取当前页面某个节点的个数

    document.getElementsByTagName(<tag_name>).length;

  4. C语言随笔2: rom ram 及其运行的过程

    内存的分配方式 五个区 :堆区.栈区.全局区.文字常量区.程序代码区 这五个区是ram中的.或者说,堆栈段.数据段.代码段 而rom中,没有堆区和栈区,只有数据段和代码段. ram是在程序运行是的内存 ...

  5. 安装Anaconda3时出现conda不是内部或者外部命令

    在win10,64位,python版本为3.7的环境下安装anaconda3的时候,无法在命令行执行conda命令,一直提示conda不是内部或者外部命令,参考网上的修改环境变量,修改完后还是没有用, ...

  6. 【前端开发API】豆瓣开放API

    转载:https://www.cnblogs.com/HuangJie-sol/articles/10884622.html#_label6 阅读目录 前言 具体api 1.正在热映 2.即将上映 3 ...

  7. Abaqus 粘聚力模型(Cohesive Model)

    目录 1. 问题描述 2. 有限元模型建立--Cohesive单元 3. 有限元模型建立--接触方法 Abaqus提供了两种方法模拟胶结特性: 使用Cohesive单元模拟胶结,通过定义材料属性和截面 ...

  8. vue基础总结

    Vue语法: new Vue({ //挂载: el: '#app', //初始化数据: data: {}, //监听 data 的数据变化: watch: { todos: { //深度监视 hand ...

  9. java处理节假日和工作时间的工具类

    import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.ArrayList; impo ...

  10. python--小游戏(循环+随机)

    1 import time 2 import random 3 4 player_victory = 0 5 enemy_victory = 0 6 a1 = True 7 while a1: 8 f ...