链接: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. nodejs学习笔记(一):centos7安装node环境

    由于windows环境安装nodejs只需要访问官方网站下载压缩包,解压即可. 首先检查自己是否安装==wget==,已安装可以跳过这步,未安装则需要先安装: linux yum install -y ...

  2. android 动画基础绘——帧动画(三)

    前言 这篇介绍帧动画. 什么是帧动画? 帧动画,非常好理解.就是轮播,比如我们看电视,其实就是一张一张播放过去的. 正文 <?xml version="1.0" encodi ...

  3. Working Plan 优先队列+贪心

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

  4. 查看mysql表空间

    ,),'MB') as data_size, concat(,),'MB') as index_size from information_schema.tables group by TABLE_S ...

  5. UVA - 12118 Inspector's Dilemma(检查员的难题)(欧拉回路)

    题意:有一个n个点的无向完全图,找一条最短路(起点终点任意),使得该道路经过E条指定的边. 分析: 1.因为要使走过的路最短,所以每个指定的边最好只走一遍,所以是欧拉道路. 2.若当前连通的道路不是欧 ...

  6. POJ 3984:迷宫问题 bfs+递归输出路径

    迷宫问题 Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 11844   Accepted: 7094 Description ...

  7. Mac系统Snail SVN 精简版配置比较、合并工具:Beyond Compare及破解

    Mac系统 Beyond Compare及破解 前言 在上一篇文章:Mac系统的SVN客户端:Snail SVN 精简版 介绍了在mac系统中svn客户端使用的是snail svn,但是当我想要把本地 ...

  8. [Mathematics][MIT 18.03] Detailed Explanation of the Frequency Problems in Second-Order Differential Equation of Oscillation System

    Well, to begin with, I'd like to say thank you to MIT open courses twice. It's their generosity that ...

  9. 创建了以个vagrant box centos php7 nginx swoole git

    php7.2.9 centos7  nginx.1.16  swoole4.4.4 下载地址 链接:https://pan.baidu.com/s/14p7xIa0ZZigRuYvZxnMsYA 提取 ...

  10. 文献及代码阅读报告 - SS-LSTM:A Hierarchical LSTM Model for Pedestrian Trajectory Prediction

    概览 简述 SS-LSTM全称Social-Scene-LSTM,是一种分层的LSTM模型,在已有的考虑相邻路人之间影响的Social-LSTM模型之上额外增加考虑了行人背景的因素.SS-LSTM架构 ...