1.单case很多清空没必要的

2.string+ char 最好用pushback

3.string +string就直接+

#include <bits/stdc++.h>
using namespace std;
typedef long long LL; const int N=2e6+10;
map<string, int> mp; string temp,res;
int num;
string s;
int n; bool Judge(char x)
{
if(x>='0'&&x<='9') return true;
if(x>='A'&&x<='Z') return true;
if(x>='a'&&x<='z') return true;
return false;
} int main()
{
getline(cin,s);
n=s.length();
bool flag = true;
int ans=0;
//mp.clear();
temp = "";
for(int i=0;i<n;i++)
{
if(s[i]>='A'&&s[i]<='Z')
s[i] = s[i] + 'a' - 'A';
if(Judge(s[i]))
{
temp.push_back(s[i]);//temp = temp + s[i];
flag=true;
}
else
{
num = temp.length();
if(num)
{
mp[temp]++;
if(mp[temp]>ans)
{
ans = mp[temp];
res = temp;
}
temp = "";
flag = false;
}
}
}
if(flag)
{
mp[temp]++;
if(mp[temp]>ans)
{
ans = mp[temp];
res = temp;
}
}
cout<<res<<" "<<ans<<endl;
return 0;
}

PAT 1071【STL string应用】的更多相关文章

  1. 深入剖析 linux GCC 4.4 的 STL string

    转自: 深入剖析 linux GCC 4.4 的 STL string 本文通过研究STL源码来剖析C++中标准模板块库std::string运行机理,重点研究了其中的引用计数和Copy-On-Wri ...

  2. 格式字符串分配stl::string

    代码非常easy,不解释,直接在代码: #include <cstdio> #include <cstdarg> #include <iostream> using ...

  3. 浅谈C++ STL string容器

    浅谈C++ STL string容器 本篇随笔简单讲解一下\(C++STL\)中\(string\)容器的使用方法及技巧. string容器的概念 其实\(string\)并不是\(STL\)的一种容 ...

  4. C++标准模板库Stand Template Library(STL)简介与STL string类

    参考<21天学通C++>第15和16章节,在对宏和模板学习之后,开启对C++实现的标准模板类STL进行简介,同时介绍简单的string类.虽然前面对于vector.deque.list等进 ...

  5. 转C++之stl::string写时拷贝导致的问题

    前几天在开发某些数据结构到文件的 Dump 和 Load 功能的时候, 遇到的一个 bug . [问题复现] 问题主要出在 Load 过程中,从文件读取数据的时候, 直接使用 fread 的去操作 s ...

  6. PAT 1071 Speech Patterns[一般]

    1071 Speech Patterns (25 分) People often have a preference among synonyms of the same word. For exam ...

  7. [转载] C++ STL string的Copy-On-Write技术

    原文: http://coolshell.cn/articles/12199.html stl的string是经过严格优化的, 深入理解对以后编程过程中应用string非常有益处, 感谢左耳朵耗子的精 ...

  8. stl string

    10.2.1 STL的string 1String概念 ²  string是STL的字符串类型,通常用来表示字符串.而在使用string之前,字符串通常是用char*表示的.string与char*都 ...

  9. [转] 深入剖析 linux GCC 4.4 的 STL string

    本文通过研究STL源码来剖析C++中标准模板块库std::string运行机理,重点研究了其中的引用计数和Copy-On-Write技术. 平台:x86_64-redhat-linux gcc ver ...

随机推荐

  1. cluster KMeans need preprocessing scale????

    Out: n_digits: 10, n_samples 1797, n_features 64 ___________________________________________________ ...

  2. Merkle 树——空间换时间,分而治之的hash表,通过根节点是由它的两个子节点内容的哈希值组成来校验数据完整性,定位篡改的数据位置

    Merkle 树 图 1.5.6.1 - Merkle 树示例 默克尔树(又叫哈希树)是一种二叉树,由一个根节点.一组中间节点和一组叶节点组成.最下面的叶节点包含存储数据或其哈希值,每个中间节点是它的 ...

  3. 如何让DIV可编辑、可拖动

    1.可编辑: <div id="move" contentEditable="true">可编辑</div> 设置contentEdit ...

  4. 计算机丨浏览器访问出现DNS_PROBE_POSSIBLE解决方法

    方法1.打开命令控制台输入: netsh winsock reset.提示重启,电脑重启后就ok了. 其他方法待续......

  5. codeforces 622C C. Not Equal on a Segment

    C. Not Equal on a Segment time limit per test 1 second memory limit per test 256 megabytes input sta ...

  6. linux命令学习笔记(22):find 命令的参数详解

    find一些常用参数的一些常用实例和一些具体用法和注意事项. .使用name选项: 文件名选项是find命令最常用的选项,要么单独使用该选项,要么和其他选项一起使用. 可以使用某种文件名 模式来匹配文 ...

  7. freeMarker(六)——程序开发指南入门

    学习笔记,选自freeMarker中文文档,译自 Email: ddekany at users.sourceforge.net 1.创建Configuration实例 首先,你应该创建一个 free ...

  8. CF221C Circling Round Treasures

    题目大意 给定一个$n\times m$的网格$(n,m\leq 20)$,每个格子都是$S\space \#\space B\space x\space .$中第一个. $S$表示起点,保证有且仅有 ...

  9. BZOJ4317: Atm的树+2051+2117

    BZOJ4317: Atm的树+2051+2117 https://lydsy.com/JudgeOnline/problem.php?id=4317 分析: 二分答案之后就变成震波那道题了. 冷静一 ...

  10. ACM学习历程—广东工业大学2016校赛决赛-网络赛E 积木积水(最值问题 || 动态规划)

    题目链接:http://gdutcode.sinaapp.com/problem.php?cid=1031&pid=4 这个题目自然会考虑到去讨论最长或者最短的板子. 笔上大概模拟一下的话,就 ...