2017杭电多校第六场1008 Kirinriki
2024-09-08 12:24:33
KirinrikiTime Limit: 4000/2000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
Problem Description
We define the distance of two strings A and B with same length n is
disA,B=∑i=0n−1|Ai−Bn−1−i| The difference between the two characters is defined as the difference in ASCII. You should find the maximum length of two non-overlapping substrings in given string S, and the distance between them are less then or equal to m.
Input
The first line of the input gives the number of test cases T; T test cases follow.
Each case begins with one line with one integers m : the limit distance of substring. Then a string S follow. Limits T≤100 0≤m≤5000 Each character in the string is lowercase letter, 2≤|S|≤5000 ∑|S|≤20000
Output
For each test case output one interge denotes the answer : the maximum length of the substring.
Sample Input
1
5 abcdefedcb
Sample Output
5
Hint
[0, 4] abcde
Source
Recommend
Statistic | Submit | Discuss | Note 题意: 已知字符串S,要求不重叠的最长子串长度,并满足两子串距离最大不超过m
|
最新文章
- webuploader上传文件,图片
- PHP修改表格(增删改)
- Android开发规范——命名 (转)
- SWD模式连接与注意事项
- javascript 把字符串转换为对象
- PHP 文件迭代器
- 使用截图方式将Excel导出为PNG图片的不可行性
- Centos7.0挂载优盘安装jdk1.7和tomcat7.0
- 在安全层面,企业如何获得更好的投资回报率 ROI?
- convertView
- linux proxy
- redis源码分析之发布订阅(pub/sub)
- java非阻塞IO(NIO)流程
- poj 3070 &;&; nyoj 148 矩阵快速幂
- spring boot集成websocket实现聊天功能和监控功能
- spring cloud(学习笔记)微服务启动错误(1)
- Python安装、卸载第三方模块
- Confluence 6 文档主题合并问答
- autocad视图汇报,像ppt那样汇报
- 51nod 1086 背包问题 V2