POJ训练计划3096_Surprising Strings(STL/map)
解题报告
题意:
思路:
map暴力。
#include <iostream>
#include <cstring>
#include <cstdio>
#include <map>
using namespace std; int main()
{
string str,ch;
int i,j;
while(cin>>str)
{
map<string,int>Map;
if(str[0]=='*')
break;
int f=0;
if(str.length()<=2){
cout<<str<<" is surprising."<<endl;
}
else
{
for(i=0;i<=str.length()-2;i++)
{
Map.clear();
for(j=0;j<str.length()-i-1;j++)
{
ch.clear();
ch+=str[j];
ch+=str[j+i+1];
if(!Map[ch])
Map[ch]=1;
else
{
f=1;
break;
}
}
}
if(f)
cout<<str<<" is NOT surprising."<<endl;
else cout<<str<<" is surprising."<<endl;
}
}
return 0;
}
POJ训练计划3096_Surprising Strings(STL/map)的更多相关文章
- POJ 3096 Surprising Strings(STL map string set vector)
题目:http://poj.org/problem?id=3096 题意:给定一个字符串S,从中找出所有有两个字符组成的子串,每当组成子串的字符之间隔着n字符时,如果没有相同的子串出现,则输出 &qu ...
- [ACM] POJ 3096 Surprising Strings (map使用)
Surprising Strings Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 5783 Accepted: 379 ...
- poj 2406 Power Strings 后缀数组解法
连续重复子串问题 poj 2406 Power Strings http://poj.org/problem?id=2406 问一个串能否写成a^n次方这种形式. 虽然这题用kmp做比较合适,但是我们 ...
- KMP POJ 2406 Power Strings
题目传送门 /* 题意:一个串有字串重复n次产生,求最大的n KMP:nex[]的性质应用,感觉对nex加深了理解 */ /************************************** ...
- stl::map之const函数访问
如何在const成员数中访问stl::map呢?例如如下代码: string ConfigFileManager::MapQueryItem(const string& name) const ...
- hdu4941 Magical Forest (stl map)
2014多校7最水的题 Magical Forest Magical Forest Time Limit: 24000/12000 MS (Java/Others) Memory Limit ...
- [CareerCup] 13.2 Compare Hash Table and STL Map 比较哈希表和Map
13.2 Compare and contrast a hash table and an STL map. How is a hash table implemented? If the numbe ...
- STL MAP及字典树在关键字统计中的性能分析
转载请注明出处:http://blog.csdn.net/mxway/article/details/21321541 在搜索引擎在通常会对关键字出现的次数进行统计,这篇文章分析下使用C++ STL中 ...
- STL MAP 反序迭代
ITS_NOTICE_MAP::reverse_iterator it = noticeMap.rbegin(); for ( ; it != noticeMap.rend(); ++it ) { I ...
随机推荐
- (8)python 类和对象
一.类和对象 python可以动态的添加删除变量和方法 类中的方法至少要有一个参数,第一个参数会被绑定到类的实例上,通常命名为self 1.构造函数 类中的构造方法名为 __init__(self,. ...
- 纯css 超链接变按钮
a{ font-family:Arial; font-size:.8em; text-align:center; margin:3px;}a:link,a:visited{ color:#A62020 ...
- awk 精彩文章
https://coolshell.cn/articles/9070.html 我从netstat命令中提取了如下信息作为用例: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ...
- numeric column can contains null
- [BZOJ 4033] 树上染色
Link: BZOJ 4033 传送门 Solution: 此题用到了计算贡献的方法, 将 多条路径的路径和 $->$ $\sum_{i=1}^{n-1} w[i]*cnt[i]$ 这样我们由 ...
- 【二分答案】【Heap-Dijkstra】bzoj2709 [Violet 1]迷宫花园
显然最短路长度随着v的变化是单调的,于是可以二分答案,据说spfa在网格图上表现较差. #include<cstdio> #include<cstring> #include& ...
- React Native学习之自定义Navigator
Navigator还是最常用的组件, 所以自己封装了一个, 使用起来也比较简单, 如下: 首先导入组件 var MLNavigator = require('../Lib/MLNavigator'); ...
- 在xcode6中使用矢量图(iPhone6置配UI)
转载出处:http://blog.xoneday.com ios应用程序是一个图像主导的产品.在开发一个应用程序时,你需要各种尺寸的图标,你需要为每个图像文件制作一个@1x尺寸和一个@2x尺寸.这样你 ...
- 定时任务-crontab
一.crond简介 crond 是linux下用来周期性的执行某种任务或等待处理某些事件的一个守护进程,与windows下的计划任务类似,当安装完成操作系统后,默认会安装此服务工具,并且会自动启动c ...
- Git -- git中本地与远程库的关联与取消
1.在本地目录下关联远程repository : git remote add origin git@github.com:git_username/repository_name.git 2.取消本 ...