HDU 5688
2016-05-27 21:58
357 查看
分析题目,发现字符排序后,查重就行。用map比较好写。
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <map>
using namespace std;
map<string, int>cnt;
int main() {
cnt.clear(); char nn[45];
int N; cin>>N;
while (N--) {
scanf ("%s", nn);
sort (nn, nn + strlen (nn) );
if (!cnt[string (nn)]) { cnt[string (nn)] = 0; }
printf ("%d\n", cnt[string (nn)]);
cnt[string (nn)] ++;
}
return 0;
}
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <map>
using namespace std;
map<string, int>cnt;
int main() {
cnt.clear(); char nn[45];
int N; cin>>N;
while (N--) {
scanf ("%s", nn);
sort (nn, nn + strlen (nn) );
if (!cnt[string (nn)]) { cnt[string (nn)] = 0; }
printf ("%d\n", cnt[string (nn)]);
cnt[string (nn)] ++;
}
return 0;
}
相关文章推荐
- 设计模式之适配器模式
- TwoNote日程清单的使用
- jquery的链式写法
- POJ-2528 Mayor's posters (线段树区间更新+离散化)
- 练习三 Problem K
- 一个人如何在一个陌生的城市生活生存下去!
- 2、内置函数enumerate(枚举)的用法
- 第十三周上机实践——项目1-分数类中的运算符重载
- Learning OpenCV: cvCreateVideoWriter to save AVI video file
- 去除bootstrap模态框半透明阴影
- vertica-对象级备份
- ORACLE数据库DBMS_JOB的创建与使用
- 1054. 求平均值 (20)
- Andriod XML Editor cannot process this input
- OC语言前期准备
- Images.xcassets文件 详解
- [notes] design principles
- 动态规划
- Spring MVC前台使用html页面作为视图,配置静态资源后Controller控制器不起作用的解决办法
- JAVA日期工具类