PAT T1015 Letter-moving Gam
双下标法找最长公共子序列(不能删除字符)
#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的更多相关文章
- 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 ...
- PAT 1032 Sharing[hash][链表][一般上]
1032 Sharing (25)(25 分) To store English words, one method is to use linked lists and store a word l ...
- 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 ...
- PAT_A1153#Decode Registration Card of PAT
Source: PAT A1153 Decode Registration Card of PAT (25 分) Description: A registration card number of ...
- PAT(B) 1057 数零壹(Java)字符串
题目链接:1057 数零壹 (20 point(s)) 题目描述 给定一串长度不超过 105 的字符串,本题要求你将其中所有英文字母的序号(字母 a-z 对应序号 1-26,不分大小写)相加,得 ...
- 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 ...
- PAT甲级【2019年3月考题】——A1157 Anniversary【25】
Zhejiang University is about to celebrate her 122th anniversary in 2019. To prepare for the celebrat ...
- PAT甲级——A1153 DecodeRegistrationCardofPAT【25】
A registration card number of PAT consists of 4 parts: the 1st letter represents the test level, nam ...
- PAT甲级——A1032 Sharing
To store English words, one method is to use linked lists and store a word letter by letter. To save ...
随机推荐
- Python 多任务(线程) day2 (1)
结论:多线程全局变量是共享的 (03) 因为多线程一般是配合使用,如果不共享,那么就要等到一个线程执行完,再把变量传递给另一个线程,就变成单线程了 但是如果多个线程同时需要修改一个全局变量,就会出现资 ...
- IDE - IDEA - tab - 方法相关的移动
1. 概述 标题可能会改 一个 tab 里方法相关的操作 2. 前提 以默认的模式编辑 tab 对我来说, 就关掉 vim 插件 3. 操作 1. 查看文件结构 概述 唤出当前文件的 结构 唤出后可以 ...
- CentOS: 网络连接故障排除
yum不能正常动作,惯性认为是需要替换BaseURL,结果后来才发现是Gateway不知什么时候被错误设定了,memo如下. 现象表现于yum不能正常动作,确认ping的操作,发现是不能解析DNS [ ...
- P&R 4
Floorplan 要做好fp需要掌握哪些知识和技能? 通常遇到fp问题大致的debug步骤和方法有哪些? 如何衡量fp的QA? 通常FP是做PR 最关键也最具技术含量的一个环节.相对于后续的PR步骤 ...
- 单选按钮 设置required属性无法进行非空验证
先看代码: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF ...
- bm坏字符 , Horspool算法 以及Sunday算法的不同
bm坏字符 , Horspool算法 以及Sunday算法的不同 一.bm中的坏字符规则思想 (1)模式串与主串从后向前匹配 (2)发现坏字符后,如果坏字符不存在于模式串中:将模式串的头字符与坏字符后 ...
- 6_15 给任务排序(UVa10305)<拓扑排序>
John有n件事情要做,不幸的是这些事情并不是各自独立的,而是有相依性的.换句话说可能有某件事情一定要在另一件事情做完之后才能做.Input每组测试数据可能有好几列.第一列有2个整数n,m.(1 &l ...
- [Python] [转] python.exe和pythonw.exe的区别(区分.py、.pyw、.pyc文件)
Windows系统搭建好Python的环境后,进入Python的安装目录,大家会发现目录中有python.exe和pythonw.exe两个程序.如下图所示: 它们到底有什么区别和联系呢? 概括说明一 ...
- Centos610安装MVN
1.下载mav安装 下载免安装版上传linux cd /opt/maven mkdir repository cd apche-maven-3.3.9/conf vi settings.xml 设置 ...
- Wordpress-微信机器人高级版
微信机器人高级版是我爱水煮鱼开发的一款插件,功能很棒,运行此插件需要同时开启WPJAM Basic插件. 高级版5.0 版本对服务器要求非常高,只支持 Linux 服务器,PHP 要求 7.2 及以上 ...