链接:https://ac.nowcoder.com/acm/contest/3665/B
来源:牛客网

题目描述

Every problem maker has a flower in their heart out of love for ACM. As a famous problem maker, hery also has a flower.
Hery define string T as flower-string if T appears more than twice in string S and |T| = k. Hery wants you to find how many flower-string in S.

输入描述:

The first line contains a string S consist of ’f’, ’l’, ’o’, ’w’, ’e’, ’r’ and an integer k.(1≤∣S∣≤105,1≤k≤100)(1 ≤ |S| ≤ 10^5, 1 ≤ k ≤ 100)(1≤∣S∣≤105,1≤k≤100)

输出描述:

Output an integer m in the first line, the number of flower − string in S.
Next m lines, each line contains a flower-string and the lexicographical order of them should be from small to large

示例1

输入

flowerflowerflower 

输出

flo
low
owe
wer

利用map储存长为k的字符串,暴力计算即可。

 #include <stdio.h>
#include <string.h>
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <sstream>
#include <ctime>
const int INF=0x3f3f3f3f;
typedef long long LL;
const int mod=1e9+;
const LL MOD=;
const double PI = acos(-);
const double eps =1e-;
#define Bug cout<<"---------------------"<<endl
const int maxn=1e5+;
using namespace std; set<string> st;
map<string,int> mp; int main()
{
#ifdef DEBUG
freopen("sample.txt","r",stdin);
#endif
// ios_base::sync_with_stdio(false);
// cin.tie(NULL); string str;
int k;
cin>>str>>k; if(k<=str.size())
{
for(int i=;i<=str.size()-k;i++)
{
string now=str.substr(i,k);
mp[now]++;
if(mp[now]==) st.insert(now);
}
} cout<<st.size()<<endl;
for(set<string>::iterator it=st.begin();it!=st.end();it++)
cout<<*it<<endl; return ;
}

-

The flower(寻找出现m次以上,长度为k的子串)的更多相关文章

  1. 【LeetCode】1461. 检查一个字符串是否包含所有长度为 K 的二进制子串 Check If a String Contains All Binary Codes of Size K

    作者: 负雪明烛 id: fuxuemingzhu 个人博客:http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 统计长度为 K 的子串个数 日期 题目地址:https ...

  2. poj2114 寻找树上存在长度为k点对,树上的分治

    寻找树上存在长度为k点对,树上的分治  代码和  这个  差不多 ,改一下判断的就好 #include <iostream> #include <algorithm> #inc ...

  3. CSU 1660 K-Cycle(dfs判断无向图中是否存在长度为K的环)

    题意:给你一个无向图,判断是否存在长度为K的环. 思路:dfs遍历以每一个点为起点是否存在长度为k的环.dfs(now,last,step)中的now表示当前点,last表示上一个访问的 点,step ...

  4. 删除从第i个位置开始,长度为len的子串

    /*字符串采用带头结点的链表存储,设计算法函数void delstring(linkstring s, int i,int len)在字符串s中删除从第i个位置开始,长度为len的子串.*//**** ...

  5. 字符串s中从第i个位置起取长度为len的子串,函数返回子串链表

    /*已知字符串采用带结点的链式存储结构(详见linksrting.h文件),请编写函数linkstring substring(linkstring s,int i,int len),在字符串s中从第 ...

  6. LCS模板,求长度,并记录子串

    //LCS模板,求长度,并记录子串  //亦可使用注释掉的那些代码,但所用空间会变大 #include<iostream> #include<cstring> #include ...

  7. 给定一个set字符和一个正数k,找出所有该做set它可以由长度构成k该字符串集合 print-all-combinations-of-given-length

    // 给定一个set字符和一个正数k,找出所有该做set它可以由长度构成k该字符串集合 /* Input: set[] = {'a', 'b'}, k = 3 Output: aaa aab aba ...

  8. leetcode-219-Contains Duplicate II(使用set来判断长度为k+1的闭区间中有没有重复元素)

    题目描述: Given an array of integers and an integer k, find out whether there are two distinct indices i ...

  9. hiho#1449 重复旋律6 求长度为k的串最大次数 后缀自动机

    题目传送门 题目大意:求长度为k的串的最大次数,把k从1到length的所有答案全部输出. 思路: 这道题放在$SAM$里就是求长度$k$对应的所有$right$集中最大的大小. 我们以$aabab$ ...

随机推荐

  1. Python MySQL 入门

    章节 Python MySQL 入门 Python MySQL 创建数据库 Python MySQL 创建表 Python MySQL 插入表 Python MySQL Select Python M ...

  2. Working Plan 优先队列+贪心

    题目链接:http://codeforces.com/gym/101987题目描述ICPC manager plans a new project which is to be carried out ...

  3. jQuery表格隔行换色和全选的实现

    1.下载jQuery,并导入:https://blog.csdn.net/weixin_44718300/article/details/88746796 2.代码实现: <!DOCTYPE h ...

  4. window10 家庭版安装docker和php开发环境

    前期工作   一.在宿主机创建文件夹 D:\wnmp\mysql57-conf D:\wnmp\mysql57-log D:\wnmp\nginx110-conf D:\wnmp\nginx110-l ...

  5. 吴裕雄--天生自然 JAVASCRIPT开发学习:while 循环

    <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title> ...

  6. UML-线程标示法

    继续前一章<缓存策略>,既然用缓存,那如何保证数据同步呢?即:缓存里的数据和DB里的数据一致. 解决:LocalProducts每隔N分钟查询并更新它的缓存(定时器) 如果LocalPro ...

  7. 解决vue-cli3不停请求 /sockjs-node/info?t= 问题

    使用cli3会遇到一直报错get不到/sockjs-node/info?t= 的问题: 如果你的项目没有用到 sockjs,那么就找到报错的地方,将其注释掉即可. 路径在/node_modules/s ...

  8. part11 Vue项目接口联调//真机测试

    何为项目接口联调? 前端代码编译好了  后端接口写好了 我们就需要去掉前端模拟数据干掉 用后端提供的数据.进行前后端的一个调试 如何联调? config目录下面 index.js 文件 dev 中pr ...

  9. 每天一点点之vue框架开发 - axios拦截器的使用

    <script> import axios from 'axios' export default { name: 'hello', data () { return { msg: 'We ...

  10. Integer和int的区别

    1.Integer是int的包装类,int则是java的一种基本数据类型 2.Integer变量必须实例化后才能使用,而int变量不需要 3.Integer实际是对象的引用,当new一个Integer ...