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

#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. dbGet(三)

    inst flat design下的instance Parent Object group, hInst, instTerm, io, pBlkg, ptn, rBlkg, sdp, topCell ...

  2. c# pcm

    using System; using System.IO; using System.Text; using System.Windows.Forms; using System.Runtime.I ...

  3. 3种常见的CSS页面布局--双飞翼布局、粘连布局、左右两列布局

    一.左右两列布局 1.代码如下,可先粘贴复制,自行运行 <!DOCTYPE html><html> <head> <meta charset="UT ...

  4. AJAX技术初级探索

    一 概念 Ajax技术能够实现页面以异步方式从服务器获取信息,无需刷新页面 Ajax的核心技术是XMLHttpRequest对象(XHR) 异步实际就是请求数据的代码不会阻塞页面向下执行 二 原生Aj ...

  5. git拉取代码

    1,用sourcetree拉取的时候 遇到  fatal: repository 'http://gitlab.xxx.com/XXX/XXX.git/' not found 2,可以直接在要存放代码 ...

  6. SDNU_ACM_ICPC_2020_Winter_Practice_1st

    A Petya is a big fan of mathematics, esecially its part related to fractions. Recently he learned th ...

  7. 【MySQL】完整性约束

    " 目录 not null default unique 单列唯一 联合唯一 primary key 单列主键 复合主键 auto_increment 步长与偏移量 foreign key ...

  8. iOS 开发之使用链式编程思想实现简单的计算器

    链式编程思想是将多个操作(多行代码)通过点号(.)链接在一起成为一句代码,使代码可读性好.例如 a(1).b(2).c(3). 链式编程思想最为关键的是,方法的返回值是block,block必须返回对 ...

  9. java 限制每隔15分钟才允许执行一次程序

    由于公司订餐平台,有个用户催单业务,每当用户点击催单按钮时,商家就会收到消息提示,如果用户频繁的发起催单请求,这样商家就会不停的收到消息提醒,所以想限制用户至少每隔15分钟才可以催单一次 我采取了以下 ...

  10. Oracle 设置NLS_CHARACTERSET字符集

    Oracle 设置NLS_CHARACTERSET字符集 sqlplus "/ as sysdba"SQL> SHUTDOWN IMMEDIATE;SQL> START ...