解题报告

id=3096">题目传送门

题意:

给一个字符串,要求。对于这个字符串空隔为k取字符对(k=0,1,2,3,4...)要求在同样的空隔取对过程汇总。整个字符串中没有一个同样字符对如:
ZGBZ:
间隔为0的字符对有: ZG、GB、BZ,三个均不同样
间隔为1的字符对有: ZG、 GZ,均不同样
间隔为2的字符对有: ZZ 仅有一个,不必比較。
这样的字符串定义为"surprising".
之后依照格式输出。

思路:

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)的更多相关文章

  1. POJ 3096 Surprising Strings(STL map string set vector)

    题目:http://poj.org/problem?id=3096 题意:给定一个字符串S,从中找出所有有两个字符组成的子串,每当组成子串的字符之间隔着n字符时,如果没有相同的子串出现,则输出 &qu ...

  2. [ACM] POJ 3096 Surprising Strings (map使用)

    Surprising Strings Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 5783   Accepted: 379 ...

  3. poj 2406 Power Strings 后缀数组解法

    连续重复子串问题 poj 2406 Power Strings http://poj.org/problem?id=2406 问一个串能否写成a^n次方这种形式. 虽然这题用kmp做比较合适,但是我们 ...

  4. KMP POJ 2406 Power Strings

    题目传送门 /* 题意:一个串有字串重复n次产生,求最大的n KMP:nex[]的性质应用,感觉对nex加深了理解 */ /************************************** ...

  5. stl::map之const函数访问

    如何在const成员数中访问stl::map呢?例如如下代码: string ConfigFileManager::MapQueryItem(const string& name) const ...

  6. hdu4941 Magical Forest (stl map)

    2014多校7最水的题   Magical Forest Magical Forest Time Limit: 24000/12000 MS (Java/Others)    Memory Limit ...

  7. [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 ...

  8. STL MAP及字典树在关键字统计中的性能分析

    转载请注明出处:http://blog.csdn.net/mxway/article/details/21321541 在搜索引擎在通常会对关键字出现的次数进行统计,这篇文章分析下使用C++ STL中 ...

  9. STL MAP 反序迭代

    ITS_NOTICE_MAP::reverse_iterator it = noticeMap.rbegin(); for ( ; it != noticeMap.rend(); ++it ) { I ...

随机推荐

  1. Socket学习总结系列(一) -- IM & Socket

    写在准备动手的时候: Socket通讯在iOS中也是很常见,自己最近也一直在学习Telegram这个开源项目,Telegram就是在Socket的基础上做的即时通讯,这个相信了解这个开源项目的也都知道 ...

  2. python3爬虫爬取煎蛋网妹纸图片(下篇)2018.6.25有效

    分析完了真实图片链接地址,下面要做的就是写代码去实现了.想直接看源代码的可以点击这里 大致思路是:获取一个页面的的html---->使用正则表达式提取出图片hash值并进行base64解码--- ...

  3. codeforces 713C C. Sonya and Problem Wihtout a Legend(dp)(将一个数组变成严格单增数组的最少步骤)

    E. Sonya and Problem Wihtout a Legend time limit per test 5 seconds memory limit per test 256 megaby ...

  4. Superbull(最大生成树)(Kruskal)

    Superbull 时间限制: 1 Sec  内存限制: 64 MB提交: 49  解决: 13[提交][状态][讨论版] 题目描述 Bessie and her friends are playin ...

  5. Counting Haybales (线段树)

    Counting Haybales 时间限制: 50 Sec  内存限制: 256 MB提交: 52  解决: 18[提交][状态][讨论版] 题目描述 Farmer John is trying t ...

  6. 【C++】const 常引用的用法

    用法: const int & a; 定义了一个整型常引用变量a. 特点: 1.不能够通过常引用变量来修改其值,如: const int & a = 10; a = 12;//编译报错 ...

  7. 【计算几何】 Codeforces Beta Round #67 (Div. 2) E. Ship's Shortest Path

    读懂题意其实是模板题.就是细节略多. #include<cstdio> #include<cmath> #include<algorithm> using name ...

  8. 【堆】bzoj1293 [SCOI2009]生日礼物

    考虑poj3320尺取法的做法,与此题基本一样,但是此题的 位置 的范围到2^31 尺取法不可. 将每种珠子所在的位置排序. 每种珠子要维护一个指针,指到已经用到这个种类的哪个珠子. 所以尺取法用堆优 ...

  9. [CF160D]Edges in MST

    [CF160D]Edges in MST 题目大意: 一个\(n(n\le10^5)\)个点,\(m(m\le10^5)\)条边的连通图.对于图中的每条边,判断它与该图最小生成树的关系: 在该图所有的 ...

  10. Spark1.4远程调试

    1)首先,我们是在使用spark-submit提交作业时,使用 --driver-java-options ”-Xdebug -Xrunjdwp:transport=dt_socket,server= ...