POJ3297+map字符串处理
简单的字符串处理题。
要注意细节!
附数据两组:
ABCC
abc
ae
AAA
abc
AAAA
abc A
a
B
a
C
a
/* */
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<algorithm>
#include<iostream>
#include<queue>
#include<map>
#include<stack>
#include<set>
#include<math.h>
using namespace std;
typedef long long int64;
//typedef __int64 int64;
typedef pair<int64,int64> PII;
#define MP(a,b) make_pair((a),(b))
const int maxn = ;
const int maxm = ;
const int inf = 0x7fffffff;
const double pi=acos(-1.0);
const double eps = 1e-; struct Node{
string name;
int cnt;
}project[ maxn ];
map<string,int>mp;
map<string,int>special;
void init(){
mp.clear();
special.clear();
}
int cmp( Node a,Node b ){
if( a.cnt!=b.cnt )
return a.cnt>b.cnt;
else
return a.name<b.name;
}
int main(){
string temp;
while( getline( cin,temp ) ){
//cout<<"temp = "<<temp<<endl;
if( ''==temp[] )
break;
if( ''==temp[] )
continue;
init();
int Num = ;
while( ){
project[ Num ].name = temp;
project[ Num ].cnt = ;
while( ){
getline( cin,temp );
//cout<<"temp = "<<temp<<endl;
if( temp.size()==&&temp[]=='' ) break;
if( ( temp[]>='a'&&temp[]<='z' )||( temp[]>=''&&temp[]<='' ) ){
if( mp[ temp ]== ){
mp[ temp ] = Num;
project[ Num ].cnt ++ ;
}
else {
if( mp[ temp ]==Num ){}
else if( special[ temp ]== ){
special[ temp ] = ;
if( project[ mp[temp] ].cnt> )
project[ mp[ temp ] ].cnt --;
}
}
}
else
break;
}
Num ++ ;
if( ''==temp[] ) break;
}
//cout<<"ok"<<endl;
sort( project+,project+Num,cmp );
for( int i=;i<Num;i++ ){
cout<<project[i].name<<" "<<project[i].cnt<<endl;
}
}
return ;
}
POJ3297+map字符串处理的更多相关文章
- 1022. Digital Library (30) -map -字符串处理
题目如下: A Digital Library contains millions of books, stored according to their titles, authors, key w ...
- 下厨房---map/字符串查询
题目描述 牛牛想尝试一些新的料理,每个料理需要一些不同的材料,问完成所有的料理需要准备多少种不同的材料. 输入描述: 每个输入包含 1 个测试用例.每个测试用例的第 i 行,表示完成第 i 件料理需要 ...
- Map字符串类型去掉空格处理
Iterator it = data.keySet().iterator(); for (; it.hasNext();) { if( data.get(key) instanceof Strin ...
- XML转换为Map通用算法实现 Java版本(Stax实现)
目前项目中需要将XML转换为Map,下面给出了自己的代码实现. 后续将为大家提供Dom版本的实现. 请各路大神给予各种优良实现. 场景: 在项目中需要解析XML文本字符串,需要将XML文本字符串映射为 ...
- javascript 自定义Map
迁移时间:2017年5月25日08:24:19 Author:Marydon 三.自定义Map数据格式 需特别注意的是: js中没有像java中的Map数据格式,js自带的map()方法用于:返回 ...
- 002---Python基本数据类型--字符串
字符串 .caret, .dropup > .btn > .caret { border-top-color: #000 !important; } .label { border: 1p ...
- Java利用FastJson一行代码转List<Map>为List<Bean>
/** * 字符串 -> json对象.实体对象.Map.List.List<Map> */ // 字符串 -> json对象 JSONObject json = JSON.p ...
- 6.Python字符串
#header { display: none !important; } } #header-spacer { width: 100%; visibility: hidden; } @media p ...
- hdu3973 AC's String 线段树+字符串hash
题目链接:http://icpc.njust.edu.cn/Problem/Hdu/3973/ 题意是:给出一个模式串,再给出一些串组成一个集合,操作分为两种,一种是替换模式串中的一个字符,还有一种是 ...
随机推荐
- Swift构造器(Initializer)与析构器(Deinitializer)
为了初始化结构体和类等类型的实例属性. 默认构造器 struct Fahrenheit { var temperature: Doubleinit(){ temperature = 32.0 } } ...
- C#中String类的几个方法(IndexOf、LastIndexOf、Substring)
String.IndexOf String.IndexOf 方法 (Char, Int32, Int32)报告指定字符在此实例中的第一个匹配项的索引.搜索从指定字符位置开始,并检查指定数量的字符位置. ...
- .Net平台开源作业调度框架Quartz.Net
Quartz.NET介绍: Quartz.NET是一个开源的作业调度框架,是OpenSymphony 的 Quartz API的.NET移植,它用C#写成,可用于winform和asp.net应用中. ...
- 关键字 virtual
Virtual是C++ OO机制中很重要的一个关键字.只要是学过C++的人都知道在类Base中加了Virtual关键字的函数就是虚拟函数(例如函数print),于是在Base的派生类Derived中就 ...
- 关键字 const
如果关键字出现在星号左边,表示被指物是常量: 如果出现在星号右边,表示指针本身是常量: 如果出现在星号两边,表示被指物和指针都是常量. void f1(const Widget* pw); //f1和 ...
- C++ 的隱式型別轉換
先上一段代碼, 這段代碼竟然可以編譯過,我的老天! class Boo { Boo(int c){ cout << "I'm Boo"; } }; void do_so ...
- 哆啦A梦连连看游戏源码完整版
这个源码是哆啦A梦连连看游戏源码完整版,也是安卓教程网android.662p.com分享过来的,哆啦A梦大家一定再熟悉不过了,这次登场的角色你能认出全部吗?赶紧把相同的小图标全部消除吧,一起体验下! ...
- 用Unitils测试BaseDao遇到的问题总结
<Spring 3.0就这么简单>.(陈雄华,林开雄)第8章,对如何用Unitils进行测试简单介绍,下面是我用Unitils进行单元测试过程中遇到的问题的总结. 1.设置好pom.xml ...
- asp.net 点击按钮,页面没有任何变化,后台代码不触发
asp.net 点击按钮,页面没有任何变化,后台代码不触发 和可能是 asp.net button 缺少validationGroup 导致的,需要查看页面的validation并且让他们抛出错误信 ...
- [OpenXml] Generate excel in memory and dump to file
public static void GenerateExcelFromStream() { using (MemoryStream memoryStream = new MemoryStream() ...