Codeup墓地-2074
src:http://codeup.cn/problem.php?id=2074
2074: 子串计算
时间限制: 1 Sec 内存限制: 32 MB
题目描述
给出一个01字符串(长度不超过100),求其每一个子串出现的次数。

输入
输入包含多行,每行一个字符串。

输出
对每个字符串,输出它所有出现次数在1次以上的子串和这个子串出现的次数,输出按字典序排序。

样例输入
1010100001
1010
样例输出
0 6
00 3
000 2
01 3
010 2
1 4
10 3
101 2
1010 2
0 2
1 2
10 2
提示
字符串前缀查找

//给出一个01字符串(长度不超过100),求其每一个子串出现的次数。
//set<struct>写法
#include<bits/stdc++.h>
using namespace std;
struct Node{string s;int t;Node(string _s,int _t):s(_s),t(_t){}friend bool operator<(Node const &a,Node const &b){return a.s<b.s;}
};
int main(){string line;while(getline(cin,line)){set<Node>st;for(int len=1;len<line.size()-1;len++){for(int i=0;i+len<line.size();i++){string s=line.substr(i,len);int pos,t=0;string l(line);while((pos=l.find(s))!=-1){l=l.replace(0,pos+1,"");t++;}st.insert(Node(s,t));}}while(!st.empty()){if((*st.begin()).t!=1)printf("%s %d\n",(*st.begin()).s.c_str(),(*st.begin()).t);st.erase(st.begin());}}return 0;
}

Codeup墓地-2074相关推荐

  1. Codeup墓地-1123

    Codeup墓地-1123 src:http://codeup.cn/problem.php?id=1123 1123: 确定排序序列 时间限制: 1 Sec 内存限制: 32 MB 题目描述 一个由 ...

  2. Codeup墓地-1107

    Codeup墓地-1107 src:http://codeup.cn/problem.php?id=1107 1107: 欧几里得游戏 时间限制: 1 Sec 内存限制: 32 MB 题目描述 小明和 ...

  3. Codeup墓地1817号A+B

    Codeup墓地链接:http://codeup.cn/ 本题链接:http://codeup.cn/problem.php?cid=100000575&pid=1 问题描述: 问题 B: A ...

  4. Codeup墓地-2337

    Codeup墓地-2337 src:http://codeup.cn/problem.php?id=2337 2337: 阻击火箭队 时间限制: 1 Sec 内存限制: 32 MB 题目描述 小明很喜 ...

  5. Codeup墓地-1985

    Codeup墓地-1985 src:http://codeup.cn/problem.php?id=1985 1985: 任务调度 时间限制: 1 Sec 内存限制: 32 MB 题目描述 读入任务调 ...

  6. Codeup墓地-2118

    Codeup墓地-2118 src:http://codeup.cn/problem.php?id=2118 2118: 非常可乐 时间限制: 1 Sec 内存限制: 32 MB 题目描述 大家一定觉 ...

  7. Codeup墓地-1098

    Codeup墓地-1098 src:http://codeup.cn/problem.php?id=1098 1098: 最少的交换 时间限制: 1 Sec 内存限制: 32 MB 题目描述 现在给你 ...

  8. Codeup墓地-2117

    Codeup墓地-2117 src:http://codeup.cn/problem.php?id=2117 2117: 确定比赛名次 时间限制: 1 Sec 内存限制: 32 MB 题目描述 有N个 ...

  9. Codeup墓地-2070

    Codeup墓地-2070 src:http://codeup.cn/problem.php?id=2070 2070: 坠落的蚂蚁 时间限制: 1 Sec 内存限制: 32 MB 题目描述 一根长度 ...

最新文章

  1. 超声波技术构建触摸界面
  2. java I/O之装饰者模式
  3. Apache Flink 零基础入门(十五)Flink DataStream编程(如何自定义DataSource)
  4. Python列表的生成
  5. 中国服务业发展的轨迹、逻辑与战略转变——改革开放40年来的经验分析
  6. dial tcp 10.96.0.1:443: i/o timeout
  7. 算法导论学习--学习笔记0527
  8. 【19】蓝桥杯之奇妙的数字(填空题)
  9. 『动态规划』矩阵连乘
  10. 【ASO优化】手游9大ASO优化方法帮你获得巨量新增!
  11. 2022年安全员-A证考题模拟考试平台操作
  12. Excel分列时拒绝让超过15位的数字变成科学计数法
  13. HTML边框圆角椭圆原理,CSS3教程:border-radius你以为就是个圆角边框吗?
  14. 最新苹果服务器认证,Sign in with Apple-苹果登录(客户端和服务端)
  15. 电脑上的打印记录在哪里查看?
  16. 学了那么久Python还什么都做不了,我觉得你该试试这个方法了
  17. 如何设置Windows10定时重启?
  18. dbSUPER:人和小鼠中的超级增强子数据库
  19. 滴滴android wear,滴滴出行(com.sdu.didi.psnger) - 6.1.21 - 应用 - 酷安
  20. 美国GeneSiC推出目前世界最高等级6.5kV/300mΩ SiC MOSFET产品

热门文章

  1. 泰山OFFICE技术讲座:奇怪的Times New Roman字体的高度
  2. Arduino_OLED电子时钟
  3. WebGL扭曲时空动画js特效
  4. 43道Python经典案例题(有答案)
  5. 制氧机语音芯片新方案,高品质低功耗NV040C语音IC
  6. uniapp--腾讯地图驾车路线规划
  7. React + Vite 实现一个音乐网站(aplayer音乐播放器 )
  8. SYNOPSYS™前视红外辐射计(FLIR)设计, 冷反射效应
  9. 智能座舱:屏幕“堆砌”不是全部,“双商”满分才是归宿
  10. ffmpeg源码阅读之avformat_open_input