字符串
文章平均质量分 51
Apollo-yyy
考研失败的华子5G工程师一枚
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
最长回文
给出一个只由小写英文字符a,b,c…y,z组成的字符串S,求S中最长回文串的长度. 回文就是正反读都是一样的字符串,如aba, abba等Input输入有多组case,不超过120组,每组输入为一行小写英文字符a,b,c…y,z组成的字符串S 两组case之间由空行隔开(该空行不用处理) 字符串长度len <= 110000Output每一行一个整数x,对应一组c...原创 2018-08-10 15:23:21 · 331 阅读 · 0 评论 -
1040 Longest Symmetric String
题目大意:输出一个字符串中最长回文串的长度。解题思路:一开始暴力写了一发,枚举起点然后扩展字符串判断是否是回文串,但这种方法本质上不包含长度为偶数的回文串,虽然各种骚操作弄了半天但是还是有一个两分的测试点过不去。无奈只好用DP写,DP数组为DP【i】【j】,含义为从i到j的字符串是否为回文串。状态转移方程为DP【i】【j】=(DP【i+1】【j-1】,条件s【i】==s【j】。否则不是回文...原创 2019-02-09 17:06:04 · 503 阅读 · 0 评论 -
1039 Course List for Student
题目大意:N名学生和K门课程,分别给出每门课程下选课学生的名字,查询每名学生选了多少门课程以及课程的编号,课程的编号要按照升序输出。解题思路:这个题难点在于如何用唯一的数字标记学生的名字。也就是设计哈希函数。如果用MAP来分配学生名字的标号的话最后一个样例过不去,不是段错误就是什么运行错误。。。由于每名学生的名字由3个大写字母和1个数字组成,可以设计一个简单的哈希函数,如果是字母的话按照2...原创 2019-01-29 10:18:35 · 472 阅读 · 0 评论 -
Language of FatMouse
We all know that FatMouse doesn’t speak English. But now he has to be prepared since our nation will join WTO soon. Thanks to Turing we have computers to help him.Input SpecificationInput consis...原创 2018-08-16 19:14:08 · 549 阅读 · 0 评论 -
codeforces 490 div3 C.Alphabetic Removals
题目大意:长度为n的字符串,按照小写字母顺序表删除k个字母(删完a才能接着删b….)解题思路:模拟即可,我用STL 队列写了一发,熟悉一些队列操作。#include<iostream>#include<cstdio>#include<fstream>#include<set>原创 2018-08-13 20:48:29 · 201 阅读 · 0 评论 -
codeforces 490 div3 B. Reversing Encryption
题目大意:一个长度为n的字符串,有k次操作,每次把范围为1-d(d是n的因子,且d从大到小)的子字符串翻转。 现在给你k次翻转后的结果,要求输出原来的字符串。解题思路:给出结果求原串,操作的过程翻转一下就可以。原来是d递减,那么现在递增,一开始不知道reverse()函数,拿模拟写了。。。用reverse()函数好简单。。 模拟代码:#include<iostre...原创 2018-08-13 20:40:57 · 232 阅读 · 0 评论 -
POJ-3461-Oulipo
The French author Georges Perec (1936–1982) once wrote a book, La disparition, without the letter ‘e’. He was a member of the Oulipo group. A quote from the book:Tout avait Pair normal, mais tout s’...原创 2018-08-08 16:19:03 · 261 阅读 · 0 评论 -
HDU-1711-Number Sequence
Given two sequences of numbers : a[1], a[2], …… , a[N], and b[1], b[2], …… , b[M] (1 <= M <= 10000, 1 <= N <= 1000000). Your task is to find a number K which make a[K] = b[1], a[K + 1] = b...原创 2018-08-08 09:48:42 · 241 阅读 · 0 评论 -
Oulipo-HDU-1686 哈希
这个题我之前用kmp板子写过一次,这次开始学习哈希,再上一个单哈希的方法,就当入门模板吧。思路:算出子字符串的哈希值,然后遍历主字符串枚举起点,算出和相同长度子串的哈希值,如果值相同则答案加1。 代码如下:#include<iostream>#include<cstdio>#include<fstream>#include&原创 2018-08-12 16:18:13 · 342 阅读 · 1 评论 -
字符串HASH算法入门
放个链接好了:字符串哈希入门转载 2018-08-11 16:56:02 · 541 阅读 · 0 评论 -
Page Numbers
«Bersoft» company is working on a new version of its most popular text editor — Bord 2010. Bord, like many other text editors, should be able to print out multipage documents. A user keys a sequence o...原创 2018-08-06 20:55:45 · 670 阅读 · 0 评论 -
Comparing Two Long Integers
You are given two very long integers a, b (leading zeroes are allowed). You should check what number a or b is greater or determine that they are equal.The input size is very large so don’t use the ...原创 2018-08-06 20:42:00 · 401 阅读 · 0 评论 -
Ostap and Grasshopper
On the way to Rio de Janeiro Ostap kills time playing with a grasshopper he took with him in a special box. Ostap builds a line of length n such that some cells of this line are empty and some contain...原创 2018-08-06 20:26:16 · 307 阅读 · 0 评论 -
Different is Good
A wise man told Kerem “Different is good” once, so Kerem wants all things in his life to be different.Kerem recently got a string s consisting of lowercase English letters. Since Kerem likes it when...原创 2018-08-06 20:11:37 · 419 阅读 · 0 评论 -
Two Substrings
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings “AB” and “BA” (the substrings can go in any order).InputThe only line of input conta...原创 2018-08-06 20:03:01 · 312 阅读 · 0 评论 -
1136 A Delayed Palindrome
题目大意:判断一个字符串是否是回文串,不是就和它的倒置字符串相加,直到结果是回文串为止。如果这样的操作进行十次后还不是回文串,那么就输出“Not found in 10 iterations.”。解题思路:用字符串模拟大整数相加即可。代码如下:#include<iostream>#include<cstdio>#include<cstring>...原创 2019-02-22 09:53:58 · 249 阅读 · 0 评论
分享