哈理工OJ 2113 Count(map计数)
来源:互联网 发布:运动鞋女跑步鞋淘宝 编辑:程序博客网 时间:2024/05/18 00:40
题目链接:
http://acm.hrbust.edu.cn/index.php?m=ProblemSet&a=showProblem&problem_id=2113
Count
Time Limit: 1000 MS Memory Limit: 32768 K
Total Submit: 119(61 users) Total Accepted: 67(58 users) Rating: Special Judge: No
Description
Given a number of strings, can you find how many strings that appears T times?
Input
The input contains multiple test cases. Each case begins with a integer N(the number of strings you will get, N<=100000), followed by N lines, each consists of a string.
The length of each string won’t longer than 20.
Output
For each test case:
There will be several lines. Echo line print two integers T and M, separated by a space.
T represents the string appears T times, M represents there are M strings that echo string appears T times.
Don’t print T or M if M <= 0. The output is ordered by T, from small to large.
Sample Input
5
BBA
BBA
BEA
DEC
CCF
Sample Output
1 3
2 1
Source
ACM-ICPC黑龙江省第九届大学生程序设计竞赛选拔赛(2)
很简单的map问题,只需要扫两遍就OK了。
下面是AC代码:
#include<cstdio>#include<cstring>#include<map>#include<iostream>#include<algorithm>using namespace std;int num[100005];int main(){ int n; while(~scanf("%d",&n)) { map<string,int>m; string a[100005]; for(int i=0;i<n;i++) { cin>>a[i]; m[a[i]]++; } memset(num,0,sizeof(num)); for(int i=0;i<n;i++) { num[m[a[i]]]++; m[a[i]]=0; } for(int i=1;i<=100000;i++) { if(num[i]) printf("%d %d\n",i,num[i]); } } return 0;}
- 哈理工OJ 2113 Count(map计数)
- hrbust 哈理工oj 2113 Count【STL水题】
- Hust oj 2113 Count(Map)
- 哈理工OJ HLG OJ 1005Counting Subsequences(map应用)(STL应用)
- 哈理工 oj 2122 旅行(map + 最短路dij算法)
- 哈理工OJ 2304 Julyed(水题)
- 哈理工oj/hrbust 2122 旅行【dij+优先队列优化+邻接表+map】
- 哈理工 oj 1721A+B=0 map or 双指针
- 哈理工OJ 2179(深搜)
- 哈理工 oj 1161 Leyni
- 哈理工OJ 1692【水题】
- 哈理工oj 2317 Game
- 哈理工oj 2002 幂集
- Time(山东理工OJ)
- 哈理工OJ 1909 理工门外的树(思维题目)
- 哈理工oj 1348 最短路径 (floyd算法)
- 哈理工 OJ Fire Maze(2次bfs)
- 哈理工OJ 1652(思维题)1652 小球移动.
- Linux中文显示设置
- XAMPP: 在 MAC OS X 下安裝 Apache + PHP + MySQL 環境
- Relevant Phrases of Annihilation SPOJ (后缀数组)
- 数据库视频总结
- 编译android内核源码然后用真机运行
- 哈理工OJ 2113 Count(map计数)
- 【笔记】PMBOK第12章项目采购管理
- 选区转路径&画笔描边路径——邮票
- 驱动学习第二讲(规范化以及misc驱动)
- git 命令 学习
- 自定义下拉选择框
- Android基础 完美打造自己的apk
- android中的MVP模式
- HDU 1224(dp46)