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 ...
随机推荐
- 训练指南 UVALive - 5135 (双连通分量)
layout: post title: 训练指南 UVALive - 5135 (双连通分量) author: "luowentaoaa" catalog: true mathja ...
- hdu6191(树上启发式合并)
hdu6191 题意 给你一棵带点权的树,每次查询 \(u\) 和 \(x\) ,求以 \(u\) 为根结点的子树上的结点与 \(x\) 异或后最大的结果. 分析 看到子树,直接上树上启发式合并,看到 ...
- luogu P1824 进击的奶牛
题目描述 Farmer John建造了一个有N(2<=N<=100,000)个隔间的牛棚,这些隔间分布在一条直线上,坐标是x1,...,xN (0<=xi<=1,000,000 ...
- [Baltic2003] Gem
[Baltic2003]Gem Time Limit: 2 Sec Memory Limit: 64 MBSubmit: 501 Solved: 320[Submit][Status][Discu ...
- Ze_Min Tree 主席树
前言 主席树,也叫可持久化线段树,所以他的本质是颗线段树,而可持久化指的是这颗线段树可以访问过去某个时刻线段树上的信息. 应用 应用的比较多的是查询区间的第k大值(因为其他的数据结构不好做). 实现 ...
- 【离线】【递推】【multiset】 Codeforces Round #401 (Div. 2) C. Alyona and Spreadsheet
对询问按右端点排序,对每一列递推出包含当前行的单调不下降串最多向前延伸多少. 用multiset维护,取个最小值,看是否小于等于该询问的左端点. #include<cstdio> #inc ...
- 【二分答案】bzoj1639 [Usaco2007 Mar]Monthly Expense 月度开支
#include<cstdio> using namespace std; #define N 100001 int n,m,a[N]; bool check(int x) { int n ...
- no such file or directory : 'users/shikx/xxx/xxx/Appirater.m'
删除此处红色的.m文件即可
- Visual Studio 断点无法命中怎么办?
经常远程调试服务器打断点是空心的,很抓狂,正确的方法应该是 #if DEBUG if (System.Diagnostics.Debugger.IsAttached) { System.Diagnos ...
- 使用gettext提取c#中的多语言占位符(nopCommerce示例篇)
i18n国际化通常的作法是使用gettext,即在源码中使用特殊的关键字来标识这个字符串将可能被翻译,如 @if (Model.IsCustomerForumModerator) { <li c ...