解题报告

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. ACM-ICPC国际大学生程序设计竞赛北京赛区(2017)网络赛

    编号 名称 通过率 通过人数 提交人数 A√水题(队友写的 Visiting Peking University 91% 1122 1228 B— Reverse Suffix Array 57% 6 ...

  2. HDU 多校1.11

  3. Largest Divisible Subset -- LeetCode

    Given a set of distinct positive integers, find the largest subset such that every pair (Si, Sj) of ...

  4. 【2-SAT】URAL - 2089 - Experienced coach

    题意:给出n对点a,b  要求从没对点中选出一个,且最终选出的点n个数不能存在相同的.输入数据满足每种数最多出现3次,最少出现1次 思路:第i对点的编号2*i, 2*i+1,   因为每个数最多出现3 ...

  5. Spring Boot企业微信点餐系统-第一章-课程介绍

    一.项目简介——技术要点 前端和后端: 后端主要技术: 微信接口技术 微信支付 微信扫码登录 微信模板消息推送 开发环境 但实际上我用的环境和这上面还是有点不一样,我服务器用的是win,到时候我会详细 ...

  6. jQuery 移除绑定事件

    移除事件 unbind(type [,data])     //data是要移除的函数 $('#btn').unbind("click"); //移除click $('#btn') ...

  7. 高性能mysql读后感

    1. 事务里的写操作,四种隔离级别,都会加排他锁. 2. 事务里的读操作,前三种隔离级别,不会加锁,最后一种隔离级别,会加共享锁. 3. 上面的写.读操作,都是隐式加的锁.  可以自己显示对读操作进行 ...

  8. Swift,函数

    1.无参数无输出的函数 func a(){ print("HI") } a() //HI 2.有参数有输出的函数 func add(a:Int,b:Int)->Int{ // ...

  9. easyui 只刷新当前页面的数据 datagrid reload 方法

    $('#refreshbtn').click(function() { $("#t_auclot").datagrid("reload",serializeFo ...

  10. python的dict如何排序

    Python的内置dictionary数据类型是无序的,通过key来获取对应的value.可是有时我们需要对dictionary中 的item进行排序输出,可能根据key,也可能根据value来排 # ...